From e57726594def943e377aef5e6f9e5f04c23f774e Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 25 Aug 2023 19:33:48 +0200 Subject: [PATCH] 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. --- scripts/startup/bl_ui/space_view3d.py | 2 +- scripts/templates_py/ui_asset_shelf.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index 275a51a3d8a..d903c2f0d47 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -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): diff --git a/scripts/templates_py/ui_asset_shelf.py b/scripts/templates_py/ui_asset_shelf.py index dd5b3af1fae..43c02f8bf14 100644 --- a/scripts/templates_py/ui_asset_shelf.py +++ b/scripts/templates_py/ui_asset_shelf.py @@ -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):