Fix topbar UI w/ no active object
authorCampbell Barton <ideasman42@gmail.com>
Fri, 20 Apr 2018 21:08:08 +0000 (23:08 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 20 Apr 2018 21:08:08 +0000 (23:08 +0200)
release/scripts/startup/bl_ui/space_topbar.py

index 7ce512ebb2aa3c54dc16bc76a12f069f161d9d66..708be478301b9a06cb0b8f93cd842a424f6551c6 100644 (file)
@@ -95,11 +95,11 @@ class TOPBAR_HT_lower_bar(Header):
     def draw_left(self, context):
         layout = self.layout
         layer = context.view_layer
-
-        act_mode_item = bpy.types.Object.bl_rna.properties['mode'].enum_items[layer.objects.active.mode]
+        object = layer.objects.active
+        object_mode = 'OBJECT' if object is None else object.mode
+        act_mode_item = bpy.types.Object.bl_rna.properties['mode'].enum_items[object_mode]
         layout.operator_menu_enum("object.mode_set", "mode", text=act_mode_item.name, icon=act_mode_item.icon)
 
-
     def draw_right(self, context):
         layout = self.layout