Fix T58683: Reload Scripts breaks toolbar button formatting
Add a function which clears internal cached operator pointers, run before reloading scripts.
This commit is contained in:
parent
68c2f7a2d0
commit
5940f6b3d9
Notes:
blender-bot
2023-02-14 06:42:54 +01:00
Referenced by issue #58683, Toolbar buttons change color and icons become off-centered after using the Reload Scripts operator
|
@ -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
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue