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/blender/makesrna/intern | |
parent | 38b211b58198f48b37473671d92d448bc48c4c67 (diff) |
Fix crashes accessing inactive screen properties
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 16 |
1 files changed, 13 insertions, 3 deletions
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) |