Page MenuHome

Fix T63892: Tools cannot be registered into some contexts (e.g. PAINT_TEXTURE)
Needs ReviewPublic

Authored by Philipp Oeser (lichtwerk) on Thu, Feb 6, 2:09 PM.

Details

Summary

This fails because some tool contexts define their tools with functions
[see the following list for context that fail]:

  • PARTICLE (_defs_particle.generate_from_brushes)
  • SCULPT (_defs_sculpt.generate_from_brushes)
  • PAINT_TEXTURE (_defs_texture_paint.generate_from_brushes)
  • PAINT_VERTEX (_defs_vertex_paint.generate_from_brushes)
  • PAINT_WEIGHT (_defs_weight_paint.generate_from_brushes)
  • PAINT_GPENCIL (_defs_gpencil_paint.generate_from_brushes)
  • SCULPT_GPENCIL (_defs_gpencil_sculpt.generate_from_brushes)
  • WEIGHT_GPENCIL (_defs_gpencil_weight.generate_from_brushes)

ToolSelectPanelHelper._tools_flatten() is usually called with
cls.tools_from_context(context) [that already yields from the function].
But when registering a tool, _tools_flatten() will still give back this
function, not a ToolDef - and we cannot get a bl_idname from that.
Suggest to just yield None in that case (we cannot really get the
ToolDefs from the function at this point without context it seems)

Diff Detail

Repository
rB Blender
Branch
T63892 (branched from master)
Build Status
Buildable 6663
Build 6663: arc lint + arc unit

Event Timeline

Campbell Barton (campbellbarton) requested changes to this revision.Thu, Feb 13, 11:01 AM

While correct, this logic should be shared across other functions too _tools_flatten_with_tool_index & _tools_flatten_with_keymap.

Suggest to use the logic from _tools_flatten_with_keymap, move this function below _tools_flatten_with_tool_index, then add your extended comment above all 3 flatten functions.

This revision now requires changes to proceed.Thu, Feb 13, 11:01 AM

address review by Campbell