diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-04-25 03:09:22 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-04-25 03:09:22 +0400 |
commit | 11c6abe53b77baefa09737fa8f615f5c734f4b63 (patch) | |
tree | af36b80d12dbde1ef38e13cda219db3f4215d8ae /source/blender/editors/screen/screen_edit.c | |
parent | 08a48b8b966825ef5f95727faeb86784e093bc33 (diff) |
Fix crash going to a scene with no camera, with an inactive 3D viewport space.
The regions of the space are stored in a different place depending if it is
active or if another space is in use. The code here was iterating over both
but it should be only one because the other might contain regions of another
space.
Diffstat (limited to 'source/blender/editors/screen/screen_edit.c')
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index b48451e4788..61abe73e7b2 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1448,6 +1448,36 @@ void ED_screen_delete(bContext *C, bScreen *sc) BKE_libblock_free(&bmain->screen, sc); } +static void ed_screen_set_3dview_camera(Scene *scene, bScreen *sc, ScrArea *sa, View3D *v3d) +{ + /* fix any cameras that are used in the 3d view but not in the scene */ + BKE_screen_view3d_sync(v3d, scene); + + if (!v3d->camera || !BKE_scene_base_find(scene, v3d->camera)) { + v3d->camera = BKE_scene_camera_find(sc->scene); + // XXX if (sc == curscreen) handle_view3d_lock(); + if (!v3d->camera) { + ARegion *ar; + ListBase *regionbase; + + /* regionbase is in different place depending if space is active */ + if (v3d == sa->spacedata.first) + regionbase = &sa->regionbase; + else + regionbase = &v3d->regionbase; + + for (ar = regionbase->first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + RegionView3D *rv3d = ar->regiondata; + if (rv3d->persp == RV3D_CAMOB) { + rv3d->persp = RV3D_PERSP; + } + } + } + } + } +} + /* only call outside of area/region loops */ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) { @@ -1487,28 +1517,8 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) while (sl) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *) sl; + ed_screen_set_3dview_camera(scene, sc, sa, v3d); - BKE_screen_view3d_sync(v3d, scene); - - if (!v3d->camera || !BKE_scene_base_find(scene, v3d->camera)) { - v3d->camera = BKE_scene_camera_find(sc->scene); - // XXX if (sc == curscreen) handle_view3d_lock(); - if (!v3d->camera) { - ListBase *regionbase[] = {&sa->regionbase, &v3d->regionbase, NULL}; - int i; - for (i = 0; regionbase[i]; i++) { - ARegion *ar; - for (ar = regionbase[i]->first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d = ar->regiondata; - if (rv3d->persp == RV3D_CAMOB) { - rv3d->persp = RV3D_PERSP; - } - } - } - } - } - } } sl = sl->next; } |