WM: default tool was being set for space types w/o tools
Add mask for space types so we don't accidentally add tools for space types that don't support it.
This commit is contained in:
@@ -2398,7 +2398,7 @@ class WM_OT_tool_set_by_name(Operator):
|
||||
if fn(context, space_type, self.name):
|
||||
return {'FINISHED'}
|
||||
else:
|
||||
self.report({'WARNING'}, f"Tool {self.name!r} not found.")
|
||||
self.report({'WARNING'}, f"Tool {self.name!r:s} not found for space {space_type!r:s}.")
|
||||
return {'CANCELLED'}
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,11 @@ struct StructRNA;
|
||||
|
||||
/* wm_toolsystem.c */
|
||||
|
||||
#define WM_TOOLSYSTEM_SPACE_MASK ( \
|
||||
(1 << SPACE_VIEW3D) | \
|
||||
(1 << SPACE_IMAGE) \
|
||||
)
|
||||
|
||||
/* Values that define a categoey of active tool. */
|
||||
typedef struct bToolKey { int space_type; int mode; } bToolKey;
|
||||
|
||||
|
||||
@@ -4474,7 +4474,9 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win)
|
||||
/* Detect changes to the state. */
|
||||
{
|
||||
bToolRef *tref = NULL;
|
||||
if (ar->regiontype == RGN_TYPE_WINDOW) {
|
||||
if ((ar->regiontype == RGN_TYPE_WINDOW) &&
|
||||
((1 << sa->spacetype) & WM_TOOLSYSTEM_SPACE_MASK))
|
||||
{
|
||||
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
||||
WorkSpace *workspace = WM_window_get_active_workspace(win);
|
||||
const bToolKey tkey = {
|
||||
|
||||
@@ -72,6 +72,9 @@ struct bToolRef *WM_toolsystem_ref_from_context(struct bContext *C)
|
||||
WorkSpace *workspace = CTX_wm_workspace(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if (((1 << sa->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) {
|
||||
return NULL;
|
||||
}
|
||||
const bToolKey tkey = {
|
||||
.space_type = sa->spacetype,
|
||||
.mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype),
|
||||
@@ -92,6 +95,7 @@ struct bToolRef_Runtime *WM_toolsystem_runtime_from_context(struct bContext *C)
|
||||
|
||||
bToolRef *WM_toolsystem_ref_find(WorkSpace *workspace, const bToolKey *tkey)
|
||||
{
|
||||
BLI_assert((1 << tkey->space_type) & WM_TOOLSYSTEM_SPACE_MASK);
|
||||
LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
|
||||
if ((tref->space_type == tkey->space_type) &&
|
||||
(tref->mode == tkey->mode))
|
||||
@@ -404,6 +408,9 @@ void WM_toolsystem_init(bContext *C)
|
||||
bScreen *screen = WM_window_get_active_screen(win);
|
||||
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
||||
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
if (((1 << sa->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) {
|
||||
continue;
|
||||
}
|
||||
const bToolKey tkey = {
|
||||
.space_type = sa->spacetype,
|
||||
.mode = WM_toolsystem_mode_from_spacetype(view_layer, sa, sa->spacetype),
|
||||
@@ -556,6 +563,8 @@ bToolRef *WM_toolsystem_ref_set_by_name(
|
||||
tkey = &tkey_from_context;
|
||||
}
|
||||
|
||||
BLI_assert((1 << tkey->space_type) & WM_TOOLSYSTEM_SPACE_MASK);
|
||||
|
||||
RNA_enum_set(&op_props, "space_type", tkey->space_type);
|
||||
RNA_boolean_set(&op_props, "cycle", cycle);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user