fix: update handler loading

This commit is contained in:
Swann Martinez 2019-07-10 17:16:44 +02:00
parent 1bb816b735
commit 134d332647
No known key found for this signature in database
GPG Key ID: 414CCAFD8DA720E1
2 changed files with 31 additions and 29 deletions

View File

@ -23,7 +23,7 @@ from bpy.app.handlers import persistent
DEPENDENCIES = {
"zmq",
"umsgpack",
"pyyaml"
"yaml"
}
@ -226,7 +226,6 @@ def register():
bpy.app.handlers.load_post.append(load_handler)
operators.register()
ui.register()

View File

@ -13,6 +13,7 @@ import bpy
from bpy_extras.io_utils import ExportHelper
import mathutils
from pathlib import Path
from bpy.app.handlers import persistent
from . import environment, client, draw, helpers, ui
from .libs import umsgpack
@ -88,6 +89,7 @@ def update_client_selected_object(context):
# TODO: cleanup
def init_datablocks():
for datatype in environment.rtypes:
if bpy.context.window_manager.session.supported_datablock[datatype].is_replicated:
@ -347,7 +349,7 @@ class SessionSnapUserOperator(bpy.types.Operator):
bl_description = "Description that shows in blender tooltips"
bl_options = {"REGISTER"}
target_client = bpy.props.StringProperty()
target_client: bpy.props.StringProperty(default="None")
@classmethod
def poll(cls, context):
@ -456,12 +458,12 @@ def get_datablock_from_update(update,context):
if item_id == 'Master Collection':
datablock_ref = bpy.context.scene
elif item_type in helpers.BPY_TYPES.keys():
datablock_ref = getattr(bpy.data, helpers.BPY_TYPES[update.id.__class__.__name__])[update.id.name]
datablock_ref = getattr(
bpy.data, helpers.BPY_TYPES[update.id.__class__.__name__])[update.id.name]
else:
if item_id in bpy.data.lights.keys():
datablock_ref = bpy.data.lights[item_id]
return datablock_ref
@ -473,6 +475,7 @@ def toogle_update_dirty(context, update):
data_ref.is_dirty = True
@persistent
def depsgraph_update(scene):
ctx = bpy.context
@ -481,7 +484,6 @@ def depsgraph_update(scene):
updates = ctx.view_layer.depsgraph.updates
username = ctx.window_manager.session.username
selected_objects = helpers.get_selected_objects(scene)
for update in reversed(updates):
@ -507,7 +509,8 @@ def depsgraph_update(scene):
client.instance.set(key)
else:
try:
getattr(bpy.data, helpers.BPY_TYPES[update.id.__class__.__name__]).remove(item)
getattr(bpy.data, helpers.BPY_TYPES[update.id.__class__.__name__]).remove(
item)
except:
pass
break