Tool System: pass space type when setting tool
authorCampbell Barton <ideasman42@gmail.com>
Wed, 16 May 2018 16:59:43 +0000 (18:59 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 16 May 2018 17:04:29 +0000 (19:04 +0200)
Internal change only, needed because object mode is now in top-bar.

release/scripts/startup/bl_operators/wm.py
release/scripts/startup/bl_ui/space_toolsystem_common.py

index f48cf69d1c9f3c11eee552493f06a4a1c97257de..a9d766b29e28e8aedf66909167972e0c9c10751c 100644 (file)
@@ -2338,7 +2338,7 @@ class WM_OT_tool_set_by_name(Operator):
 
     def execute(self, context):
         from bl_ui.space_toolsystem_common import activate_by_name
-        if activate_by_name(context, self.name):
+        if activate_by_name(context, context.space_data.type, self.name):
             return {'FINISHED'}
         else:
             self.report({'WARNING'}, f"Tool {self.name!r} not found.")
index ed683bcc3120b2dbd7b91ec302cda6d1385e09a5..b58bff7cf32ab221d1ab11c61585a69918e39105 100644 (file)
@@ -253,11 +253,11 @@ class ToolSelectPanelHelper:
         return None, 0
 
     @staticmethod
-    def _tool_get_by_name(context, text):
+    def _tool_get_by_name(context, space_type, text):
         """
         Return the active Python tool definition and index (if in sub-group, else -1).
         """
-        cls = ToolSelectPanelHelper._tool_class_from_space_type(context.space_data.type)
+        cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type)
         if cls is not None:
             context_mode = context.mode
             for item, index in ToolSelectPanelHelper._tools_flatten_with_tool_index(cls.tools_from_context(context)):
@@ -556,15 +556,15 @@ class WM_MT_toolsystem_submenu(Menu):
                 continue
             tool_def, icon_name = ToolSelectPanelHelper._tool_vars_from_def(item, context_mode)
             icon_value = ToolSelectPanelHelper._icon_value_from_icon_handle(icon_name)
-            props = layout.operator(
+            layout.operator(
                 "wm.tool_set_by_name",
                 text=item.text,
                 icon_value=icon_value,
             ).name = item.text
 
 
-def activate_by_name(context, text):
-    item, index = ToolSelectPanelHelper._tool_get_by_name(context, text)
+def activate_by_name(context, space_type, text):
+    item, index = ToolSelectPanelHelper._tool_get_by_name(context, space_type, text)
     if item is not None:
         context_mode = context.mode
         tool_def, icon_name = ToolSelectPanelHelper._tool_vars_from_def(item, context_mode)