Merge branch '163-support-adding-scene-during-the-session' into '132-fix-undo-edit-last-operation-redo-handling-2'

Resolve "Support adding scene during the session"

See merge request slumber/multi-user!95
This commit is contained in:
Swann Martinez
2021-01-22 10:22:14 +00:00
2 changed files with 12 additions and 12 deletions

View File

@ -281,13 +281,9 @@ class BlScene(BlDatablock):
bl_icon = 'SCENE_DATA'
bl_reload_parent = False
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.diff_method = DIFF_JSON
def _construct(self, data):
instance = bpy.data.scenes.new(data["name"])
instance.uuid = self.uuid
return instance
def _load_implementation(self, data, target):

View File

@ -960,16 +960,13 @@ def sanitize_deps_graph(dummy):
rm_cpt = 0
for node_key in session.list():
node = session.get(node_key)
if not node.resolve(construct=False):
if node is None or not node.resolve(construct=False):
try:
session.remove(node.uuid)
rm_cpt+=1
except NonAuthorizedOperationError:
continue
logging.debug(f"Sanitize took { utils.current_milli_time()-start}ms")
logging.info(f"Removed {rm_cpt} nodes")
logging.debug(f"Sanitize took { utils.current_milli_time()-start}ms, Removed {rm_cpt} nodes")
@persistent
def load_pre_handler(dummy):
@ -1025,8 +1022,15 @@ def depsgraph_evaluation(scene):
logging.error(e)
else:
continue
# A new scene is created
elif isinstance(update.id, bpy.types.Scene):
ref = session.get(reference=update.id)
if ref:
ref.resolve()
else:
scn_uuid = session.add(update.id)
session.commit(scn_uuid)
session.push(scn_uuid, check_data=False)
def register():
from bpy.utils import register_class