Commit: 704b336899dd0a308f9160fa53478d2aaed9f730
Author: Sergey Sharybin
Date:   Mon Jan 28 12:47:39 2019 +0100
Branches: master
https://developer.blender.org/rB704b336899dd0a308f9160fa53478d2aaed9f730

Make scene statistics to respect locked interface

Interface is being locked when some destructive operations
are called from non-main thread.

This was causing crash with particles in T60065.

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

M       source/blender/editors/include/ED_info.h
M       source/blender/editors/space_info/info_stats.c
M       source/blender/makesrna/intern/rna_scene.c

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

diff --git a/source/blender/editors/include/ED_info.h 
b/source/blender/editors/include/ED_info.h
index 072b1a135a3..8c9dd61a0da 100644
--- a/source/blender/editors/include/ED_info.h
+++ b/source/blender/editors/include/ED_info.h
@@ -27,8 +27,10 @@
 #ifndef __ED_INFO_H__
 #define __ED_INFO_H__
 
+struct Main;
+
 /* info_stats.c */
 void ED_info_stats_clear(struct ViewLayer *view_layer);
-const char *ED_info_stats_string(struct Scene *scene, struct ViewLayer 
*view_layer);
+const char *ED_info_stats_string(struct Main *bmain, struct Scene *scene, 
struct ViewLayer *view_layer);
 
 #endif /*  __ED_INFO_H__ */
diff --git a/source/blender/editors/space_info/info_stats.c 
b/source/blender/editors/space_info/info_stats.c
index de406ccdc59..23ef5076c93 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -38,6 +38,7 @@
 #include "DNA_mesh_types.h"
 #include "DNA_meta_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_windowmanager_types.h"
 
 #include "BLI_listbase.h"
 #include "BLI_math.h"
@@ -52,6 +53,7 @@
 #include "BKE_displist.h"
 #include "BKE_key.h"
 #include "BKE_layer.h"
+#include "BKE_main.h"
 #include "BKE_paint.h"
 #include "BKE_particle.h"
 #include "BKE_editmesh.h"
@@ -597,8 +599,15 @@ void ED_info_stats_clear(ViewLayer *view_layer)
        }
 }
 
-const char *ED_info_stats_string(Scene *scene, ViewLayer *view_layer)
+const char *ED_info_stats_string(Main *bmain, Scene *scene, ViewLayer 
*view_layer)
 {
+       /* Loopin through dependency graph when interface is locked in not safe.
+        * Thew interface is marked as locked when jobs wants to modify the
+        * dependency graph. */
+       wmWindowManager *wm = bmain->wm.first;
+       if (wm->is_interface_locked) {
+               return "";
+       }
        Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
        if (!view_layer->stats) {
                stats_update(depsgraph, view_layer);
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index 44e41fd60e1..e3e26a9a5bd 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -691,6 +691,11 @@ static void rna_Scene_volume_set(PointerRNA *ptr, float 
value)
                BKE_sound_set_scene_volume(scene, value);
 }
 
+static const char *rna_Scene_statistics_string_get(Scene *scene, Main *bmain, 
ViewLayer *view_layer)
+{
+       return ED_info_stats_string(bmain, scene, view_layer);
+}
+
 static void rna_Scene_framelen_update(Main *UNUSED(bmain), Scene *scene, 
PointerRNA *UNUSED(ptr))
 {
        scene->r.framelen = (float)scene->r.framapto / (float)scene->r.images;
@@ -6633,7 +6638,8 @@ void RNA_def_scene(BlenderRNA *brna)
        RNA_def_property_float_funcs(prop, NULL, "rna_Scene_volume_set", NULL);
 
        /* Statistics */
-       func = RNA_def_function(srna, "statistics", "ED_info_stats_string");
+       func = RNA_def_function(srna, "statistics", 
"rna_Scene_statistics_string_get");
+       RNA_def_function_flag(func, FUNC_USE_MAIN);
        parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Active 
layer");
        RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
        parm = RNA_def_string(func, "statistics", NULL, 0, "Statistics", "");

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to