[Bf-blender-cvs] [5940f6b3d9c] master: Fix T58683: Reload Scripts breaks toolbar button formatting

Campbell Barton noreply at git.blender.org
Mon Sep 30 18:01:06 CEST 2019


Commit: 5940f6b3d9cfa99a1b893b6149d36ee0a8c51584
Author: Campbell Barton
Date:   Tue Oct 1 01:59:31 2019 +1000
Branches: master
https://developer.blender.org/rB5940f6b3d9cfa99a1b893b6149d36ee0a8c51584

Fix T58683: Reload Scripts breaks toolbar button formatting

Add a function which clears internal cached operator pointers,
run before reloading scripts.

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

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_query.c
M	source/blender/editors/space_script/script_edit.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_init_exit.c

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

diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 5326888036e..f5721c008b2 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2454,6 +2454,8 @@ void UI_widgetbase_draw_cache_end(void);
 void UI_theme_init_default(void);
 void UI_style_init_default(void);
 
+void UI_interface_tag_script_reload(void);
+
 /* Special drawing for toolbar, mainly workarounds for inflexible icon sizing. */
 #define USE_UI_TOOLBAR_HACK
 
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 27a33a38b15..f05100e9065 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -6689,3 +6689,8 @@ void UI_exit(void)
   ui_resources_free();
   ui_but_clipboard_free();
 }
+
+void UI_interface_tag_script_reload(void)
+{
+  ui_interface_tag_script_reload_queries();
+}
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 5c73b41b778..4351b75eb86 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -993,4 +993,7 @@ void ui_rna_collection_search_cb(const struct bContext *C,
 /* interface_ops.c */
 bool ui_jump_to_target_button_poll(struct bContext *C);
 
+/* interface_queries.c */
+void ui_interface_tag_script_reload_queries(void);
+
 #endif /* __INTERFACE_INTERN_H__ */
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index 457d01c5dc8..34b1070f8b4 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -137,15 +137,15 @@ bool ui_but_has_array_value(const uiBut *but)
                PROP_COORDS));
 }
 
+static wmOperatorType *g_ot_tool_set_by_id = NULL;
 bool UI_but_is_tool(const uiBut *but)
 {
   /* very evil! */
   if (but->optype != NULL) {
-    static wmOperatorType *ot = NULL;
-    if (ot == NULL) {
-      ot = WM_operatortype_find("WM_OT_tool_set_by_id", false);
+    if (g_ot_tool_set_by_id == NULL) {
+      g_ot_tool_set_by_id = WM_operatortype_find("WM_OT_tool_set_by_id", false);
     }
-    if (but->optype == ot) {
+    if (but->optype == g_ot_tool_set_by_id) {
       return true;
     }
   }
@@ -615,3 +615,14 @@ ARegion *ui_screen_region_find_mouse_over(bScreen *screen, const wmEvent *event)
 }
 
 /** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Manage Internal State
+ * \{ */
+
+void ui_interface_tag_script_reload_queries(void)
+{
+  g_ot_tool_set_by_id = NULL;
+}
+
+/** \} */
diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c
index 48248fe1dd2..2be05785d2b 100644
--- a/source/blender/editors/space_script/script_edit.c
+++ b/source/blender/editors/space_script/script_edit.c
@@ -106,6 +106,7 @@ static bool script_test_modal_operators(bContext *C)
 
 static int script_reload_exec(bContext *C, wmOperator *op)
 {
+
 #ifdef WITH_PYTHON
 
   /* clear running operators */
@@ -114,6 +115,8 @@ static int script_reload_exec(bContext *C, wmOperator *op)
     return OPERATOR_CANCELLED;
   }
 
+  WM_script_tag_reload();
+
   /* TODO, this crashes on netrender and keying sets, need to look into why
    * disable for now unless running in debug mode */
   WM_cursor_wait(1);
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 568b904dcb7..2d9fa9e5ab6 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -102,6 +102,8 @@ void WM_init_opengl(struct Main *bmain);
 void WM_check(struct bContext *C);
 void WM_reinit_gizmomap_all(struct Main *bmain);
 
+void WM_script_tag_reload(void);
+
 uint *WM_window_pixels_read(struct wmWindowManager *wm, struct wmWindow *win, int r_size[2]);
 
 int WM_window_pixels_x(const struct wmWindow *win);
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 6a6861ae697..70d83153840 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -681,3 +681,12 @@ void WM_exit(bContext *C)
 
   exit(G.is_break == true);
 }
+
+/**
+ * Needed for cases when operators are re-registered
+ * (when operator type pointers are stored).
+ */
+void WM_script_tag_reload(void)
+{
+  UI_interface_tag_script_reload();
+}



More information about the Bf-blender-cvs mailing list