Skip to content

Commit

Permalink
Avoid operator call when registering
Browse files Browse the repository at this point in the history
Avoid operator call when registering
  • Loading branch information
keianhzo committed Dec 18, 2023
1 parent 985bcfa commit 3534bb0
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions addons/io_hubs_addon/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,20 +409,24 @@ def draw(self, context):
text='Setup')


def add_instance(context):
prefs = context.window_manager.hubs_scene_debugger_prefs
new_instance = prefs.hubs_instances.add()
new_instance.name = "Demo Hub"
new_instance.url = "https://hubs.mozilla.com/demo"
prefs.hubs_instance_idx = len(
prefs.hubs_instances) - 1

save_prefs(context)


class HubsSceneDebuggerInstanceAdd(bpy.types.Operator):
bl_idname = "hubs_scene.scene_debugger_instance_add"
bl_label = "Add Server Instance"
bl_options = {'REGISTER', 'UNDO'}

def execute(self, context):
prefs = context.window_manager.hubs_scene_debugger_prefs
new_instance = prefs.hubs_instances.add()
new_instance.name = "Demo Hub"
new_instance.url = "https://hubs.mozilla.com/demo"
prefs.hubs_instance_idx = len(
prefs.hubs_instances) - 1

save_prefs(context)
add_instance(context)

return {'FINISHED'}

Expand Down Expand Up @@ -627,7 +631,7 @@ def init():

prefs = bpy.context.window_manager.hubs_scene_debugger_prefs
if len(prefs.hubs_instances) == 0:
bpy.ops.hubs_scene.scene_debugger_instance_add('INVOKE_DEFAULT')
add_instance(bpy.context)


@persistent
Expand Down

0 comments on commit 3534bb0

Please sign in to comment.