Fix #145987: Brush selector available in Image Editor Mask mode

The keymap `km_image_paint` righfully includes both
`VIEW3D_AST_brush_texture_paint` and `IMAGE_AST_brush_paint` since
painting can be done in both Editors.

So we want to improve upon polling.

Three parent classes involved: `ImageAssetShelf`, `View3DAssetShelf`,
both inherit from `BrushAssetShelf`

`IMAGE_AST_brush_paint` (inherits from `ImageAssetShelf`) was already
checking for being in paint mode (so that Asset Shelf already wasnt
showing), but `VIEW3D_AST_brush_texture_paint` (inherits from
`View3DAssetShelf`) was permissive (doesnt have specialized poll, relies
on the "mother" classes `BrushAssetShelf` which only checks for an
active object and if that active objects `mode` equals the Assets Shelfs
"mode"). This can be true if you have an object in Texture Paint mode in
the 3DView.

So to make shelves like `VIEW3D_AST_brush_texture_paint` **not** pass
their poll in the Image Editor, add a specific poll case.

NOTE: the report also mentiones a crash when actually selecting a "bad"
brush from the "bad" asset shelf. Since that scenario is now impossible
to reach, the crash has not been investigated further.

Pull Request: https://projects.blender.org/blender/blender/pulls/146071
This commit is contained in:
Philipp Oeser
2025-09-22 15:56:52 +02:00
committed by Philipp Oeser
parent 2f02866519
commit af601e01fa

View File

@@ -9099,6 +9099,16 @@ class VIEW3D_AST_brush_texture_paint(View3DAssetShelf, bpy.types.AssetShelf):
mode_prop = "use_paint_image"
brush_type_prop = "image_brush_type"
@classmethod
def poll(cls, context):
if not super().poll(context):
return False
# bl_space_type from #View3DAssetShelf is ignored for popup asset shelves.
# Avoid this to be called from the Image Editor (both
# #IMAGE_AST_brush_paint and #VIEW3D_AST_brush_texture_paint are included
# in the #km_image_paint keymap). See #145987.
return context.space_data.type != 'IMAGE_EDITOR'
class VIEW3D_AST_brush_gpencil_paint(View3DAssetShelf, bpy.types.AssetShelf):
mode = 'PAINT_GREASE_PENCIL'