[Bf-blender-cvs] [a9394aa48e3] master: Fix crashes accessing inactive screen properties

Campbell Barton noreply at git.blender.org
Thu Mar 26 05:41:35 CET 2020


Commit: a9394aa48e36daf08402a5781258977f66414ba0
Author: Campbell Barton
Date:   Thu Mar 26 15:10:27 2020 +1100
Branches: master
https://developer.blender.org/rBa9394aa48e36daf08402a5781258977f66414ba0

Fix crashes accessing inactive screen properties

===================================================================

M	source/blender/editors/screen/screen_edit.c
M	source/blender/makesrna/intern/rna_space.c

===================================================================

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)



More information about the Bf-blender-cvs mailing list