[Bf-blender-cvs] [8f495326bf1] blender2.8: Fix operators adding manipulators multiple times

Campbell Barton noreply at git.blender.org
Thu Oct 19 13:47:06 CEST 2017


Commit: 8f495326bf12c5f23bd6bd7c1e4d71147593f663
Author: Campbell Barton
Date:   Thu Oct 19 22:44:51 2017 +1100
Branches: blender2.8
https://developer.blender.org/rB8f495326bf12c5f23bd6bd7c1e4d71147593f663

Fix operators adding manipulators multiple times

Running spin or bisect twice in a row added widget groups each time.

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

M	source/blender/editors/mesh/editmesh_bisect.c
M	source/blender/editors/mesh/editmesh_extrude.c
M	source/blender/windowmanager/manipulators/WM_manipulator_api.h
M	source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c

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

diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c
index c9f083e2089..ca84de74b3d 100644
--- a/source/blender/editors/mesh/editmesh_bisect.c
+++ b/source/blender/editors/mesh/editmesh_bisect.c
@@ -200,7 +200,7 @@ static int mesh_bisect_modal(bContext *C, wmOperator *op, const wmEvent *event)
 		{
 			View3D *v3d = CTX_wm_view3d(C);
 			if (v3d && (v3d->twtype & V3D_MANIPULATOR_DRAW)) {
-				WM_manipulator_group_type_add("MESH_WGT_bisect");
+				WM_manipulator_group_type_ensure("MESH_WGT_bisect");
 			}
 		}
 #endif
@@ -675,6 +675,9 @@ static void manipulator_mesh_bisect_draw_prepare(
         const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
 {
 	ManipulatorGroup *man = mgroup->customdata;
+	if (man->data.op->next) {
+		man->data.op = WM_operator_last_redo((bContext *)man->data.context);
+	}
 	manipulator_mesh_bisect_update_from_op(man);
 }
 
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index 9b6c7c08b13..f6db7a48108 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -765,7 +765,7 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e
 	if (ret & OPERATOR_FINISHED) {
 		/* Setup manipulators */
 		if (v3d && (v3d->twtype & V3D_MANIPULATOR_DRAW)) {
-			WM_manipulator_group_type_add("MESH_WGT_spin");
+			WM_manipulator_group_type_ensure("MESH_WGT_spin");
 		}
 	}
 #endif
@@ -1159,6 +1159,9 @@ static void manipulator_mesh_spin_draw_prepare(
         const bContext *UNUSED(C), wmManipulatorGroup *mgroup)
 {
 	ManipulatorSpinGroup *man = mgroup->customdata;
+	if (man->data.op->next) {
+		man->data.op = WM_operator_last_redo((bContext *)man->data.context);
+	}
 	manipulator_mesh_spin_update_from_op(man);
 }
 
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_api.h b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
index 726e560a061..14cc5e9f137 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_api.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
@@ -274,7 +274,7 @@ void WM_manipulatormaptype_group_free(struct wmManipulatorGroupTypeRef *wgt);
 /* -------------------------------------------------------------------- */
 /* ManipulatorGroup */
 
-/* Add/Remove (High level API) */
+/* Add/Ensure/Remove (High level API) */
 
 void WM_manipulator_group_type_add_ptr_ex(
         struct wmManipulatorGroupType *wgt,
@@ -283,6 +283,13 @@ void WM_manipulator_group_type_add_ptr(
         struct wmManipulatorGroupType *wgt);
 void WM_manipulator_group_type_add(const char *idname);
 
+void WM_manipulator_group_type_ensure_ptr_ex(
+        struct wmManipulatorGroupType *wgt,
+        struct wmManipulatorMapType *mmap_type);
+void WM_manipulator_group_type_ensure_ptr(
+        struct wmManipulatorGroupType *wgt);
+void WM_manipulator_group_type_ensure(const char *idname);
+
 void WM_manipulator_group_type_remove_ptr_ex(
         struct Main *bmain, struct wmManipulatorGroupType *wgt,
         struct wmManipulatorMapType *mmap_type);
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c
index 1675be861d6..cc902f2acdb 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c
@@ -700,14 +700,12 @@ void WM_manipulator_group_type_add_ptr_ex(
 
 	WM_manipulatorconfig_update_tag_init(mmap_type, wgt);
 }
-
 void WM_manipulator_group_type_add_ptr(
         wmManipulatorGroupType *wgt)
 {
 	wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params);
 	WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type);
 }
-
 void WM_manipulator_group_type_add(const char *idname)
 {
 	wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);
@@ -715,6 +713,27 @@ void WM_manipulator_group_type_add(const char *idname)
 	WM_manipulator_group_type_add_ptr(wgt);
 }
 
+void WM_manipulator_group_type_ensure_ptr_ex(
+        wmManipulatorGroupType *wgt,
+        wmManipulatorMapType *mmap_type)
+{
+	wmManipulatorGroupTypeRef *wgt_ref = WM_manipulatormaptype_group_find_ptr(mmap_type, wgt);
+	if (wgt_ref == NULL) {
+		WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type);
+	}
+}
+void WM_manipulator_group_type_ensure_ptr(
+        wmManipulatorGroupType *wgt)
+{
+	wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params);
+	WM_manipulator_group_type_ensure_ptr_ex(wgt, mmap_type);
+}
+void WM_manipulator_group_type_ensure(const char *idname)
+{
+	wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);
+	BLI_assert(wgt != NULL);
+	WM_manipulator_group_type_ensure_ptr(wgt);
+}
 
 void WM_manipulator_group_type_remove_ptr_ex(
         struct Main *bmain, wmManipulatorGroupType *wgt,
@@ -723,14 +742,12 @@ void WM_manipulator_group_type_remove_ptr_ex(
 	WM_manipulatormaptype_group_unlink(NULL, bmain, mmap_type, wgt);
 	WM_manipulatorgrouptype_free_ptr(wgt);
 }
-
 void WM_manipulator_group_type_remove_ptr(
         struct Main *bmain, wmManipulatorGroupType *wgt)
 {
 	wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure(&wgt->mmap_params);
 	WM_manipulator_group_type_remove_ptr_ex(bmain, wgt, mmap_type);
 }
-
 void WM_manipulator_group_type_remove(struct Main *bmain, const char *idname)
 {
 	wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(idname, false);



More information about the Bf-blender-cvs mailing list