Fix missing context attribute access in asset shelf polls

When creating a new main window, the `context.object` attribute wouldn't
exist, causing an error message to be printed.

Rather than checking if the attribute extists, query the mode from
context directly (this is always available), rather than querying it
through the active object.
This commit is contained in:
Julian Eisel
2023-08-25 19:33:48 +02:00
parent 3220912760
commit e57726594d
2 changed files with 2 additions and 2 deletions

View File

@@ -8335,7 +8335,7 @@ class VIEW3D_AST_sculpt_brushes(bpy.types.AssetShelf):
if not prefs.experimental.use_extended_asset_browser:
return False
return bool(context.object and context.object.mode == 'SCULPT')
return context.mode == 'SCULPT'
@classmethod
def asset_poll(cls, asset):

View File

@@ -7,7 +7,7 @@ class MyAssetShelf(bpy.types.AssetShelf):
@classmethod
def poll(cls, context):
return bool(context.object and context.object.mode == 'OBJECT')
return context.mode == 'OBJECT'
@classmethod
def asset_poll(cls, asset):