[Bf-blender-cvs] [05bd957] id-remap: Some more fixes, and make Outliner's delete available for all IDs, not only libraries!

Bastien Montagne noreply at git.blender.org
Fri Dec 4 17:52:37 CET 2015


Commit: 05bd9572a6c8d96043e1afae7bb5800e9549700f
Author: Bastien Montagne
Date:   Fri Dec 4 17:48:00 2015 +0100
Branches: id-remap
https://developer.blender.org/rB05bd9572a6c8d96043e1afae7bb5800e9549700f

Some more fixes, and make Outliner's delete available for all IDs, not only libraries!

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

M	source/blender/editors/space_outliner/outliner_edit.c
M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/editors/space_outliner/outliner_ops.c
M	source/blender/editors/space_outliner/outliner_tools.c

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

diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index dff0e14..dba7d64 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -299,48 +299,48 @@ void OUTLINER_OT_item_rename(wmOperatorType *ot)
 	ot->poll = ED_operator_outliner_active;
 }
 
-/* Library delete --------------------------------------------------- */
+/* ID delete --------------------------------------------------- */
 
-static void lib_delete(bContext *C, TreeElement *te, TreeStoreElem *tselem)
+static void id_delete(bContext *C, TreeElement *te, TreeStoreElem *tselem)
 {
 	Main *bmain = CTX_data_main(C);
-	Library *lib = (Library *)tselem->id;
+	ID *id = tselem->id;
 
-	BLI_assert(te->idcode == ID_LI && lib != NULL && lib->parent == NULL);
+	BLI_assert(te->idcode != 0 && id != NULL);
+	BLI_assert(te->idcode != ID_LI || ((Library *)id)->parent == NULL);
 	UNUSED_VARS_NDEBUG(te);
 
-	BKE_libblock_delete(bmain, lib);
+	BKE_libblock_delete(bmain, id);
 
 	WM_event_add_notifier(C, NC_WINDOW, NULL);
 }
 
-void lib_delete_cb(
+void id_delete_cb(
         bContext *C, Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem,
         void *UNUSED(user_data))
 {
-	lib_delete(C, te, tselem);
+	id_delete(C, te, tselem);
 }
 
-static int outliner_lib_delete_invoke_do(bContext *C, ReportList *reports, TreeElement *te, const float mval[2])
+static int outliner_id_delete_invoke_do(bContext *C, ReportList *reports, TreeElement *te, const float mval[2])
 {
 	if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) {
 		TreeStoreElem *tselem = TREESTORE(te);
 
-		if (te->idcode == ID_LI && tselem->id) {
-			if (((Library *)tselem->id)->parent) {
+		if (te->idcode != 0 && tselem->id) {
+			if (te->idcode == ID_LI && ((Library *)tselem->id)->parent) {
 				BKE_reportf(reports, RPT_ERROR_INVALID_INPUT,
 				            "Cannot delete indirectly linked library '%s'", ((Library *)tselem->id)->filepath);
 				return OPERATOR_CANCELLED;
 			}
-
-			lib_delete(C, te, tselem);
+			id_delete(C, te, tselem);
 			return OPERATOR_FINISHED;
 		}
 	}
 	else {
 		for (te = te->subtree.first; te; te = te->next) {
 			int ret;
-			if ((ret = outliner_lib_delete_invoke_do(C, reports, te, mval))) {
+			if ((ret = outliner_id_delete_invoke_do(C, reports, te, mval))) {
 				return ret;
 			}
 		}
@@ -349,7 +349,7 @@ static int outliner_lib_delete_invoke_do(bContext *C, ReportList *reports, TreeE
 	return 0;
 }
 
-static int outliner_lib_delete_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static int outliner_id_delete_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
 	ARegion *ar = CTX_wm_region(C);
 	SpaceOops *soops = CTX_wm_space_outliner(C);
@@ -363,7 +363,7 @@ static int outliner_lib_delete_invoke(bContext *C, wmOperator *op, const wmEvent
 	for (te = soops->tree.first; te; te = te->next) {
 		int ret;
 
-		if ((ret = outliner_lib_delete_invoke_do(C, op->reports, te, fmval))) {
+		if ((ret = outliner_id_delete_invoke_do(C, op->reports, te, fmval))) {
 			return ret;
 		}
 	}
@@ -371,13 +371,13 @@ static int outliner_lib_delete_invoke(bContext *C, wmOperator *op, const wmEvent
 	return OPERATOR_CANCELLED;
 }
 
-void OUTLINER_OT_lib_delete(wmOperatorType *ot)
+void OUTLINER_OT_id_delete(wmOperatorType *ot)
 {
-	ot->name = "Delete Library";
-	ot->idname = "OUTLINER_OT_lib_delete";
-	ot->description = "Delete the library under cursorn (needs a save/reload)";
+	ot->name = "Delete Datablock";
+	ot->idname = "OUTLINER_OT_id_delete";
+	ot->description = "Delete the ID under cursor";
 
-	ot->invoke = outliner_lib_delete_invoke;
+	ot->invoke = outliner_id_delete_invoke;
 	ot->poll = ED_operator_outliner_active;
 }
 
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index afc986f..b42a19e 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -182,7 +182,7 @@ void item_lib_reload_cb(
         struct bContext *C, struct Scene *scene, struct TreeElement *te,
         struct TreeStoreElem *tsep, struct TreeStoreElem *tselem, void *user_data);
 
-void lib_delete_cb(
+void id_delete_cb(
         struct bContext *C, struct Scene *scene, struct TreeElement *te,
         struct TreeStoreElem *tsep, struct TreeStoreElem *tselem, void *user_data);
 
@@ -195,7 +195,7 @@ void OUTLINER_OT_item_rename(struct wmOperatorType *ot);
 void OUTLINER_OT_lib_relocate(struct wmOperatorType *ot);
 void OUTLINER_OT_lib_reload(struct wmOperatorType *ot);
 
-void OUTLINER_OT_lib_delete(struct wmOperatorType *ot);
+void OUTLINER_OT_id_delete(struct wmOperatorType *ot);
 
 void OUTLINER_OT_show_one_level(struct wmOperatorType *ot);
 void OUTLINER_OT_show_active(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index 83d91c5..74dc47c 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -47,14 +47,14 @@ void outliner_operatortypes(void)
 	WM_operatortype_append(OUTLINER_OT_select_border);
 	WM_operatortype_append(OUTLINER_OT_item_openclose);
 	WM_operatortype_append(OUTLINER_OT_item_rename);
-	WM_operatortype_append(OUTLINER_OT_lib_delete);
-	WM_operatortype_append(OUTLINER_OT_lib_relocate);
 	WM_operatortype_append(OUTLINER_OT_operation);
 	WM_operatortype_append(OUTLINER_OT_scene_operation);
 	WM_operatortype_append(OUTLINER_OT_object_operation);
 	WM_operatortype_append(OUTLINER_OT_group_operation);
 	WM_operatortype_append(OUTLINER_OT_lib_operation);
+	WM_operatortype_append(OUTLINER_OT_lib_relocate);
 	WM_operatortype_append(OUTLINER_OT_id_operation);
+	WM_operatortype_append(OUTLINER_OT_id_delete);
 	WM_operatortype_append(OUTLINER_OT_id_remap);
 	WM_operatortype_append(OUTLINER_OT_data_operation);
 	WM_operatortype_append(OUTLINER_OT_animdata_operation);
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index d05b5e1..92ddbd4 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -991,6 +991,7 @@ typedef enum eOutliner_PropGroupOps {
 	OL_GROUPOP_UNLINK = 1,
 	OL_GROUPOP_LOCAL,
 	OL_GROUPOP_LINK,
+	OL_GROUPOP_DELETE,
 	OL_GROUPOP_REMAP,
 	OL_GROUPOP_INSTANCE,
 	OL_GROUPOP_TOGVIS,
@@ -1003,6 +1004,7 @@ static EnumPropertyItem prop_group_op_types[] = {
 	{OL_GROUPOP_UNLINK, "UNLINK",     0, "Unlink Group", ""},
 	{OL_GROUPOP_LOCAL, "LOCAL",       0, "Make Local Group", ""},
 	{OL_GROUPOP_LINK, "LINK",         0, "Link Group Objects to Scene", ""},
+    {OL_GROUPOP_DELETE, "DELETE",     0, "Delete Group", "WARNING: no undo"},
     {OL_GROUPOP_REMAP, "REMAP",       0, "Remap Users",
      "Make all users of selected datablocks to use instead current (clicked) one"},
 	{OL_GROUPOP_INSTANCE, "INSTANCE", 0, "Instance Groups in Scene", ""},
@@ -1038,6 +1040,9 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op)
 		case OL_GROUPOP_INSTANCE:
 			outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_instance_cb, NULL);
 			break;
+		case OL_GROUPOP_DELETE:
+			WM_operator_name_call(C, "OUTLINER_OT_id_delete", WM_OP_INVOKE_REGION_WIN, NULL);
+			break;
 		case OL_GROUPOP_REMAP:
 			WM_operator_name_call(C, "OUTLINER_OT_id_remap", WM_OP_INVOKE_REGION_WIN, NULL);
 			break;
@@ -1094,6 +1099,7 @@ typedef enum eOutlinerIdOpTypes {
 	OUTLINER_IDOP_UNLINK,
 	OUTLINER_IDOP_LOCAL,
 	OUTLINER_IDOP_SINGLE,
+	OUTLINER_IDOP_DELETE,
 	OUTLINER_IDOP_REMAP,
 	
 	OUTLINER_IDOP_FAKE_ADD,
@@ -1108,6 +1114,7 @@ static EnumPropertyItem prop_id_op_types[] = {
 	{OUTLINER_IDOP_UNLINK, "UNLINK", 0, "Unlink", ""},
 	{OUTLINER_IDOP_LOCAL, "LOCAL", 0, "Make Local", ""},
 	{OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""},
+    {OUTLINER_IDOP_DELETE, "DELETE", 0, "Delete", "WARNING: no undo"},
     {OUTLINER_IDOP_REMAP, "REMAP", 0, "Remap Users",
      "Make all users of selected datablocks to use instead current (clicked) one"},
 	{OUTLINER_IDOP_FAKE_ADD, "ADD_FAKE", 0, "Add Fake User",
@@ -1199,6 +1206,13 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op)
 			}
 			break;
 		}
+		case OUTLINER_IDOP_DELETE:
+		{
+			if (idlevel > 0) {
+				WM_operator_name_call(C, "OUTLINER_OT_id_delete", WM_OP_INVOKE_REGION_WIN, NULL);
+			}
+			break;
+		}
 		case OUTLINER_IDOP_REMAP:
 		{
 			if (idlevel > 0) {
@@ -1283,7 +1297,7 @@ typedef enum eOutlinerLibOpTypes {
 
 static EnumPropertyItem outliner_lib_op_type_items[] = {
 	{OL_LIB_RENAME, "RENAME", 0, "Rename", ""},
-    {OL_LIB_DELETE, "DELETE", 0, "Delete", "Delete this library and all its item from Blender (needs a save/reload)"},
+    {OL_LIB_DELETE, "DELETE", 0, "Delete", "Delete this library and all its item from Blender - WARNING: no undo"},
     {OL_LIB_RELOCATE, "RELOCATE", 0, "Relocate", "Select a new path for this library, and reload all its data"},
     {OL_LIB_RELOAD, "RELOAD", 0, "Reload", "Reload all data from this library"},
 	{0, NULL, 0, NULL, NULL}
@@ -1317,13 +1331,7 @@ static int outliner_lib_operation_exec(bContext *C, wmOperator *op)
 		}
 		case OL_LIB_DELETE:
 		{
-			/* delete */
-			outliner_do_libdata_operation(C, scene, soops, &soops->tree, lib_delete_cb, NULL);
-
-			WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL);
-			/* Note: no undo possible here really, not 100% sure why... Probably because of library optimisations
-			 *       in undo/redo process? */
-			/* ED_undo_push(C, "Rename"); */
+			WM_operator_name_call(C, "OUTLINER_OT_id_delete", WM_OP_INVOKE_REGION_WIN, NULL);
 			break;
 		}
 		case OL_LIB_RELOCATE:




More information about the Bf-blender-cvs mailing list