Fix bug since r3135: when image/vector layer are set (in)visible, the legend crashed.
Fix bug since r3135: when image/vector layer are set (in)visible, the legend crashed.

flamingo-geocms/flamingo,B3Partners/flamingo,mvdstruijk/flamingo,flamingo-geocms/flamingo,flamingo-geocms/flamingo,flamingo-geocms/flamingo,mvdstruijk/flamingo,mvdstruijk/flamingo,mvdstruijk/flamingo,B3Partners/flamingo,B3Partners/flamingo,B3Partners/flamingo