Skip to content

Commit 1618e86

Browse files
committed
fix for must restart blender when installing
1 parent 8686604 commit 1618e86

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ def register():
5555
bpy.types.Mesh.SIMLOADER = bpy.props.PointerProperty(type=SIMLOADER_mesh_property)
5656

5757

58+
# manually call this function once
59+
# so when addon being installed, it can run correctly
60+
# because scene is not used, so pass None into it
61+
SIMLOADER_initilize(None)
62+
5863
def unregister():
5964
for cls in classes:
6065
bpy.utils.unregister_class(cls)

simloader/messanger.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ def selected_callback():
1313

1414

1515
def subscribe_to_selected():
16-
# A known problem of this function,
17-
# This function will not be executed, when the first time this addon is installed.
18-
# It will start to work, e.g. restart the blender, then in `load_post` function, this function will be called and start to work
1916
import simloader
17+
18+
# because current implementation may subscribe twice
19+
# so clear once to avoid duplication
20+
bpy.msgbus.clear_by_owner(simloader)
21+
2022
bpy.msgbus.subscribe_rna(
2123
key=(bpy.types.LayerObjects, 'active'),
2224
# don't know why it needs this owner, so I set owner to this module `simloader`

0 commit comments

Comments
 (0)