[Bf-blender-cvs] [012483b6e4a] master: Fix T60880: Assert deleting grease pencil object from outliner

Campbell Barton noreply at git.blender.org
Mon Feb 25 06:53:48 CET 2019


Commit: 012483b6e4a1453c3e990127db001617997a9d64
Author: Campbell Barton
Date:   Mon Feb 25 16:51:59 2019 +1100
Branches: master
https://developer.blender.org/rB012483b6e4a1453c3e990127db001617997a9d64

Fix T60880: Assert deleting grease pencil object from outliner

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

M	source/blender/editors/space_outliner/outliner_collections.c
M	source/blender/editors/space_outliner/outliner_tools.c

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

diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index 8acda1f6f87..67126a3e155 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -42,6 +42,7 @@
 
 #include "WM_api.h"
 #include "WM_types.h"
+#include "WM_message.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -263,8 +264,11 @@ static TreeTraversalAction collection_find_data_to_edit(TreeElement *te, void *c
 
 static int collection_delete_exec(bContext *C, wmOperator *op)
 {
+	struct wmMsgBus *mbus = CTX_wm_message_bus(C);
 	Main *bmain = CTX_data_main(C);
 	Scene *scene = CTX_data_scene(C);
+	ViewLayer *view_layer = CTX_data_view_layer(C);
+	const Base *basact_prev = BASACT(view_layer);
 	SpaceOutliner *soops = CTX_wm_space_outliner(C);
 	struct CollectionEditData data = {.scene = scene, .soops = soops,};
 	bool hierarchy = RNA_boolean_get(op->ptr, "hierarchy");
@@ -292,6 +296,10 @@ static int collection_delete_exec(bContext *C, wmOperator *op)
 
 	WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
 
+	if (basact_prev != BASACT(view_layer)) {
+		WM_msg_publish_rna_prop(mbus, &scene->id, view_layer, LayerObjects, active);
+	}
+
 	return OPERATOR_FINISHED;
 }
 
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 6418f196468..b1911895bf2 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -70,6 +70,7 @@
 
 #include "WM_api.h"
 #include "WM_types.h"
+#include "WM_message.h"
 
 #include "UI_interface.h"
 #include "UI_view2d.h"
@@ -962,9 +963,6 @@ static void object_batch_delete_hierarchy_cb(
 		tselem->id = NULL;
 #endif
 	}
-
-	DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
-	WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
 }
 
 /* **************************************** */
@@ -1001,6 +999,7 @@ static const EnumPropertyItem prop_object_op_types[] = {
 
 static int outliner_object_operation_exec(bContext *C, wmOperator *op)
 {
+	struct wmMsgBus *mbus = CTX_wm_message_bus(C);
 	Main *bmain = CTX_data_main(C);
 	Scene *scene = CTX_data_scene(C);
 	wmWindow *win = CTX_wm_window(C);
@@ -1043,6 +1042,9 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
 		WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
 	}
 	else if (event == OL_OP_DELETE) {
+		ViewLayer *view_layer = CTX_data_view_layer(C);
+		const Base *basact_prev = BASACT(view_layer);
+
 		outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_delete_cb);
 
 		/* XXX: tree management normally happens from draw_outliner(), but when
@@ -1055,9 +1057,15 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
 		DEG_relations_tag_update(bmain);
 		str = "Delete Objects";
 		DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
-		WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
+		if (basact_prev != BASACT(view_layer)) {
+			WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
+			WM_msg_publish_rna_prop(mbus, &scene->id, view_layer, LayerObjects, active);
+		}
 	}
 	else if (event == OL_OP_DELETE_HIERARCHY) {
+		ViewLayer *view_layer = CTX_data_view_layer(C);
+		const Base *basact_prev = BASACT(view_layer);
+
 		/* Keeping old 'safe and slow' code for a bit (new one enabled on 28/01/2019). */
 		if (G.debug_value == 666) {
 			outliner_do_object_operation_ex(
@@ -1079,6 +1087,10 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
 		str = "Delete Object Hierarchy";
 		DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
 		WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
+		if (basact_prev != BASACT(view_layer)) {
+			WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
+			WM_msg_publish_rna_prop(mbus, &scene->id, view_layer, LayerObjects, active);
+		}
 	}
 	else if (event == OL_OP_REMAP) {
 		outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_remap_cb, NULL);



More information about the Bf-blender-cvs mailing list