Fix T58683: Reload Scripts breaks toolbar button formatting.
Assuming it's actually necessary to do this check very efficiently, replace the hack based on caching a pointer, with a different one that caches the string comparison result in the operator object.
This commit is contained in:
parent
44d042094e
commit
ba90d2efa5
Notes:
blender-bot
2023-02-14 05:44:22 +01:00
Referenced by commit 68c2f7a2d0
, Revert "Fix T58683: Reload Scripts breaks toolbar button formatting."
Referenced by issue #58683, Toolbar buttons change color and icons become off-centered after using the Reload Scripts operator
|
@ -139,17 +139,7 @@ bool ui_but_has_array_value(const uiBut *but)
|
|||
|
||||
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 (but->optype == ot) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return but->optype && but->optype->is_tool_button;
|
||||
}
|
||||
|
||||
bool UI_but_has_tooltip_label(const uiBut *but)
|
||||
|
|
|
@ -773,6 +773,8 @@ typedef struct wmOperatorType {
|
|||
/** Flag last for padding */
|
||||
short flag;
|
||||
|
||||
/** Is the operator used by tool buttons, hack for fast checking. */
|
||||
bool is_tool_button;
|
||||
} wmOperatorType;
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
* Operator Registry.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "CLG_log.h"
|
||||
|
@ -127,6 +129,9 @@ static void wm_operatortype_append__end(wmOperatorType *ot)
|
|||
ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP);
|
||||
RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
|
||||
|
||||
/* A hack for efficiently detecting buttons with this specific operator. */
|
||||
ot->is_tool_button = STREQ(ot->idname, "WM_OT_tool_set_by_id");
|
||||
|
||||
BLI_ghash_insert(global_ops_hash, (void *)ot->idname, ot);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue