Merge remote-tracking branch 'origin/master' into blender2.8
[blender.git] / source / blender / blenkernel / intern / image.c
index bd2373a59d50060b0ba6d6d38aa92daca4c8dff9..d720dc41abf117d68ab93dfb42084848727c7345 100644 (file)
@@ -81,6 +81,7 @@
 #include "BKE_scene.h"
 #include "BKE_node.h"
 #include "BKE_sequencer.h" /* seq_foreground_frame_get() */
+#include "BKE_workspace.h"
 
 #include "BLF_api.h"
 
@@ -2609,19 +2610,19 @@ void BKE_image_walk_all_users(const Main *mainp, void *customdata,
                }
        }
 
+       for (Camera *cam = mainp->camera.first; cam; cam = cam->id.next) {
+               for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) {
+                       callback(bgpic->ima, &bgpic->iuser, customdata);
+               }
+       }
+
        /* image window, compo node users */
        for (wm = mainp->wm.first; wm; wm = wm->id.next) { /* only 1 wm */
                for (win = wm->windows.first; win; win = win->next) {
-                       ScrArea *sa;
-                       for (sa = win->screen->areabase.first; sa; sa = sa->next) {
-                               if (sa->spacetype == SPACE_VIEW3D) {
-                                       View3D *v3d = sa->spacedata.first;
-                                       BGpic *bgpic;
-                                       for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) {
-                                               callback(bgpic->ima, &bgpic->iuser, customdata);
-                                       }
-                               }
-                               else if (sa->spacetype == SPACE_IMAGE) {
+                       const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
+
+                       for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+                               if (sa->spacetype == SPACE_IMAGE) {
                                        SpaceImage *sima = sa->spacedata.first;
                                        callback(sima->image, &sima->iuser, customdata);
                                }