diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-03-26 07:10:27 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-03-26 07:32:40 +0300 |
commit | a9394aa48e36daf08402a5781258977f66414ba0 (patch) | |
tree | e93c7917f622de16ebe54de3872c8000a584c40c /source | |
parent | 38b211b58198f48b37473671d92d448bc48c4c67 (diff) |
Fix crashes accessing inactive screen properties
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 16 |
2 files changed, 14 insertions, 4 deletions
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index f25f685f2e1..0151a0fcb0d 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1666,7 +1666,7 @@ Scene *ED_screen_scene_find_with_window(const bScreen *screen, } } - BLI_assert(0); + /* Can by NULL when accessing a screen that isn't active. */ return NULL; } diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 9826d921dce..cf515792252 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -859,7 +859,12 @@ static void rna_SpaceView3D_use_local_camera_set(PointerRNA *ptr, bool value) if (!value) { Scene *scene = ED_screen_scene_find(sc, G_MAIN->wm.first); - v3d->camera = scene->camera; + /* NULL if the screen isn't in an active window (happens when setting from Python). + * This could be moved to the update function, in that case the scene wont relate to the screen + * so keep it working this way. */ + if (scene != NULL) { + v3d->camera = scene->camera; + } } } @@ -868,8 +873,13 @@ static float rna_View3DOverlay_GridScaleUnit_get(PointerRNA *ptr) View3D *v3d = (View3D *)(ptr->data); bScreen *screen = (bScreen *)ptr->owner_id; Scene *scene = ED_screen_scene_find(screen, G_MAIN->wm.first); - - return ED_view3d_grid_scale(scene, v3d, NULL); + if (scene != NULL) { + return ED_view3d_grid_scale(scene, v3d, NULL); + } + else { + /* When accessed from non-active screen. */ + return 1.0f; + } } static PointerRNA rna_SpaceView3D_region_3d_get(PointerRNA *ptr) |