Page MenuHome

Toolsystem: Fix error for groups with diffrent amount of tools between modes
ClosedPublic

Authored by David Friedli (hlorus) on Apr 15 2020, 3:43 PM.

Details

Summary

Currently when a toolgroup doesn't contain the same amount of tools between all modes an error can occur:

Traceback (most recent call last):
  File "/home/david/blender-git/build_linux_lite/bin/2.83/scripts/startup/bl_operators/wm.py", line 1687, in execute
    if fn(context, space_type, self.name, as_fallback=self.as_fallback):
  File "/home/david/blender-git/build_linux_lite/bin/2.83/scripts/startup/bl_ui/space_toolsystem_common.py", line 994, in activate_by_id
    _activate_by_item(context, space_type, item, index, as_fallback=as_fallback)
  File "/home/david/blender-git/build_linux_lite/bin/2.83/scripts/startup/bl_ui/space_toolsystem_common.py", line 956, in _activate_by_item
    item_fallback, _index = cls._tool_get_active_by_index(context, select_index)
  File "/home/david/blender-git/build_linux_lite/bin/2.83/scripts/startup/bl_ui/space_toolsystem_common.py", line 394, in _tool_get_active_by_index
    item = item[index]
IndexError: tuple index out of range

Steps to reproduce:
-start blender with default settings
-in the texteditor open following script (which is a modified version of the 'ui_tool_simple.py' template):


-run the script
-in the 3dview activate the newly registered tool 'My Circle Select' (last tool in the first tool-group)
-switch to editmode while 'My Circle Select' is the active tool
-error should appear

This patch adds an additional check to see if the stored index in ToolSelectPanelHelper._tool_group_active is valid for the new context.

Diff Detail

Repository
rB Blender
Branch
master
Build Status
Buildable 7588
Build 7588: arc lint + arc unit

Event Timeline

David Friedli (hlorus) requested review of this revision.Apr 15 2020, 3:43 PM

LGTM, but I have little experience in this code, so Campbell should make the decision.

This revision is now accepted and ready to land.Apr 15 2020, 4:27 PM

Thanks for the patch, committed more general fix rB56cd92413f8f: Fix tool-system index error with mode-specific tools added to groups
as I found it was possible to get index errors elsewhere in this case too.

Hey, great to see that this is solved now, thanks a lot!