This comes from a question on BSE where someone was altering a theme setting in a method that was added to the TOPBAR_HT_upper_bar
class.
When this appended method is altering a theme color, the 3Dviewport gizmos fail to work properly, while the question reports gizmo highlighting fails and drags are delayed, I found the gizmos didn’t respond at all.
Is altering a theme setting (or any preferences/data) allowed during a UI draw? Can this be considered a bug? Is there something that can be done to prevent this or can warning messages be generated? Something like when an addon accesses data during registration. Does appending a method circumvent existing preventions?
Issue creating code :-
def TEST_HT_header_color_change(self, context):
if bpy.context.scene.tool_settings.use_keyframe_insert_auto == True:
bpy.context.preferences.themes[0].topbar.space.header = (0.4, 0.000000, 0.000000, 1.000000)
else:
bpy.context.preferences.themes[0].topbar.space.header = (0.137255, 0.137255, 0.137255, 1.000000)
def register():
bpy.types.TOPBAR_HT_upper_bar.append(TEST_HT_header_color_change)
def unregister():
bpy.types.TOPBAR_HT_upper_bar.remove(TEST_HT_header_color_change)