[Bf-blender-cvs] [bc71074d0a1] blender-v2.83-release: Fix T75922: Removing custom orientation doesn't update gizmo

Campbell Barton noreply at git.blender.org
Mon Apr 20 11:14:08 CEST 2020


Commit: bc71074d0a1a8b29b3d96a4879b9cbed165c9879
Author: Campbell Barton
Date:   Mon Apr 20 19:09:04 2020 +1000
Branches: blender-v2.83-release
https://developer.blender.org/rBbc71074d0a1a8b29b3d96a4879b9cbed165c9879

Fix T75922: Removing custom orientation doesn't update gizmo

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

M	source/blender/editors/include/ED_transform.h
M	source/blender/editors/transform/transform_ops.c
M	source/blender/editors/transform/transform_orientations.c

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

diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index 2a5803cbc4d..beba4a7199b 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -123,7 +123,7 @@ struct bContext;
 void BIF_clearTransformOrientation(struct bContext *C);
 void BIF_removeTransformOrientation(struct bContext *C, struct TransformOrientation *ts);
 void BIF_removeTransformOrientationIndex(struct bContext *C, int index);
-void BIF_createTransformOrientation(struct bContext *C,
+bool BIF_createTransformOrientation(struct bContext *C,
                                     struct ReportList *reports,
                                     const char *name,
                                     const bool use_view,
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 31b85cdf3a8..36f42992573 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -223,6 +223,9 @@ static int delete_orientation_exec(bContext *C, wmOperator *UNUSED(op))
 
   WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
 
+  struct wmMsgBus *mbus = CTX_wm_message_bus(C);
+  WM_msg_publish_rna_prop(mbus, &scene->id, scene, Scene, transform_orientation_slots);
+
   return OPERATOR_FINISHED;
 }
 
@@ -233,12 +236,11 @@ static int delete_orientation_invoke(bContext *C, wmOperator *op, const wmEvent
 
 static bool delete_orientation_poll(bContext *C)
 {
-  Scene *scene = CTX_data_scene(C);
-
   if (ED_operator_areaactive(C) == 0) {
     return 0;
   }
 
+  Scene *scene = CTX_data_scene(C);
   return ((scene->orientation_slots[SCE_ORIENT_DEFAULT].type >= V3D_ORIENT_CUSTOM) &&
           (scene->orientation_slots[SCE_ORIENT_DEFAULT].index_custom != -1));
 }
@@ -264,6 +266,7 @@ static int create_orientation_exec(bContext *C, wmOperator *op)
   const bool overwrite = RNA_boolean_get(op->ptr, "overwrite");
   const bool use_view = RNA_boolean_get(op->ptr, "use_view");
   View3D *v3d = CTX_wm_view3d(C);
+  Scene *scene = CTX_data_scene(C);
 
   RNA_string_get(op->ptr, "name", name);
 
@@ -274,10 +277,18 @@ static int create_orientation_exec(bContext *C, wmOperator *op)
     return OPERATOR_CANCELLED;
   }
 
-  BIF_createTransformOrientation(C, op->reports, name, use_view, use, overwrite);
+  if (!BIF_createTransformOrientation(C, op->reports, name, use_view, use, overwrite)) {
+    BKE_report(op->reports, RPT_ERROR, "Unable to create orientation");
+    return OPERATOR_CANCELLED;
+  }
+
+  if (use) {
+    struct wmMsgBus *mbus = CTX_wm_message_bus(C);
+    WM_msg_publish_rna_prop(mbus, &scene->id, scene, Scene, transform_orientation_slots);
+    WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
+  }
 
   WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
-  WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C));
 
   return OPERATOR_FINISHED;
 }
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 423990b3713..76823adfd20 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -296,7 +296,7 @@ bool createSpaceNormalTangent(float mat[3][3], const float normal[3], const floa
   return true;
 }
 
-void BIF_createTransformOrientation(bContext *C,
+bool BIF_createTransformOrientation(bContext *C,
                                     ReportList *reports,
                                     const char *name,
                                     const bool use_view,
@@ -333,6 +333,7 @@ void BIF_createTransformOrientation(bContext *C,
   if (activate && ts != NULL) {
     BIF_selectTransformOrientation(C, ts);
   }
+  return (ts != NULL);
 }
 
 TransformOrientation *addMatrixSpace(bContext *C,



More information about the Bf-blender-cvs mailing list