feat: initial undo tests
This commit is contained in:
parent
8a8cc0b322
commit
cd1e535a56
@ -44,7 +44,7 @@ from . import environment
|
|||||||
|
|
||||||
|
|
||||||
DEPENDENCIES = {
|
DEPENDENCIES = {
|
||||||
("replication", '0.1.17'),
|
("replication", '0.1.18'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ class BlDatablock(ReplicatedDatablock):
|
|||||||
else:
|
else:
|
||||||
self.diff_method = DIFF_BINARY
|
self.diff_method = DIFF_BINARY
|
||||||
|
|
||||||
def resolve(self):
|
def resolve(self, construct = True):
|
||||||
datablock_ref = None
|
datablock_ref = None
|
||||||
datablock_root = getattr(bpy.data, self.bl_id)
|
datablock_root = getattr(bpy.data, self.bl_id)
|
||||||
datablock_ref = utils.find_from_attr('uuid', self.uuid, datablock_root)
|
datablock_ref = utils.find_from_attr('uuid', self.uuid, datablock_root)
|
||||||
@ -143,14 +143,20 @@ class BlDatablock(ReplicatedDatablock):
|
|||||||
try:
|
try:
|
||||||
datablock_ref = datablock_root[self.data['name']]
|
datablock_ref = datablock_root[self.data['name']]
|
||||||
except Exception:
|
except Exception:
|
||||||
name = self.data.get('name')
|
if construct:
|
||||||
logging.debug(f"Constructing {name}")
|
name = self.data.get('name')
|
||||||
datablock_ref = self._construct(data=self.data)
|
logging.debug(f"Constructing {name}")
|
||||||
|
datablock_ref = self._construct(data=self.data)
|
||||||
|
for i in range(bpy.context.preferences.edit.undo_steps+1):
|
||||||
|
bpy.ops.ed.undo_push(message="Multiuser history flush")
|
||||||
|
|
||||||
if datablock_ref:
|
if datablock_ref is not None:
|
||||||
setattr(datablock_ref, 'uuid', self.uuid)
|
setattr(datablock_ref, 'uuid', self.uuid)
|
||||||
|
self.instance = datablock_ref
|
||||||
self.instance = datablock_ref
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def remove_instance(self):
|
def remove_instance(self):
|
||||||
"""
|
"""
|
||||||
|
@ -274,10 +274,11 @@ class BlObject(BlDatablock):
|
|||||||
|
|
||||||
# MODIFIERS
|
# MODIFIERS
|
||||||
modifiers = getattr(instance,'modifiers', None )
|
modifiers = getattr(instance,'modifiers', None )
|
||||||
|
data["modifiers"] = {}
|
||||||
if modifiers:
|
if modifiers:
|
||||||
dumper.include_filter = None
|
dumper.include_filter = None
|
||||||
dumper.depth = 1
|
dumper.depth = 1
|
||||||
data["modifiers"] = {}
|
|
||||||
for index, modifier in enumerate(modifiers):
|
for index, modifier in enumerate(modifiers):
|
||||||
data["modifiers"][modifier.name] = dumper.dump(modifier)
|
data["modifiers"][modifier.name] = dumper.dump(modifier)
|
||||||
|
|
||||||
|
@ -98,6 +98,10 @@ def initialize_session():
|
|||||||
|
|
||||||
bpy.ops.session.apply_armature_operator('INVOKE_DEFAULT')
|
bpy.ops.session.apply_armature_operator('INVOKE_DEFAULT')
|
||||||
|
|
||||||
|
# Step 0: Clearing history
|
||||||
|
for i in range(bpy.context.preferences.edit.undo_steps+1):
|
||||||
|
bpy.ops.ed.undo_push(message="Multiuser history flush")
|
||||||
|
|
||||||
|
|
||||||
@session_callback('on_exit')
|
@session_callback('on_exit')
|
||||||
def on_connection_end(reason="none"):
|
def on_connection_end(reason="none"):
|
||||||
@ -926,8 +930,14 @@ def sanitize_deps_graph(dummy):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
if session and session.state['STATE'] == STATE_ACTIVE:
|
if session and session.state['STATE'] == STATE_ACTIVE:
|
||||||
|
session.lock_operations()
|
||||||
|
|
||||||
for node_key in session.list():
|
for node_key in session.list():
|
||||||
session.get(node_key).resolve()
|
node = session.get(node_key)
|
||||||
|
node.resolve(construct=False)
|
||||||
|
|
||||||
|
session.unlock_operations()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
@ -978,6 +988,16 @@ def depsgraph_evaluation(scene):
|
|||||||
# # New items !
|
# # New items !
|
||||||
# logger.error("UPDATE: ADD")
|
# logger.error("UPDATE: ADD")
|
||||||
|
|
||||||
|
@persistent
|
||||||
|
def unlock(dummy):
|
||||||
|
if session and session.state['STATE'] == STATE_ACTIVE:
|
||||||
|
session.unlock_operations()
|
||||||
|
|
||||||
|
@persistent
|
||||||
|
def lock(dummy):
|
||||||
|
if session and session.state['STATE'] == STATE_ACTIVE:
|
||||||
|
session.lock_operations()
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
from bpy.utils import register_class
|
from bpy.utils import register_class
|
||||||
@ -985,6 +1005,11 @@ def register():
|
|||||||
for cls in classes:
|
for cls in classes:
|
||||||
register_class(cls)
|
register_class(cls)
|
||||||
|
|
||||||
|
bpy.app.handlers.undo_post.append(unlock)
|
||||||
|
bpy.app.handlers.undo_pre.append(lock)
|
||||||
|
bpy.app.handlers.redo_pre.append(unlock)
|
||||||
|
bpy.app.handlers.redo_post.append(lock)
|
||||||
|
|
||||||
bpy.app.handlers.undo_post.append(sanitize_deps_graph)
|
bpy.app.handlers.undo_post.append(sanitize_deps_graph)
|
||||||
bpy.app.handlers.redo_post.append(sanitize_deps_graph)
|
bpy.app.handlers.redo_post.append(sanitize_deps_graph)
|
||||||
|
|
||||||
@ -1000,6 +1025,10 @@ def unregister():
|
|||||||
for cls in reversed(classes):
|
for cls in reversed(classes):
|
||||||
unregister_class(cls)
|
unregister_class(cls)
|
||||||
|
|
||||||
|
bpy.app.handlers.undo_post.remove(unlock)
|
||||||
|
bpy.app.handlers.undo_pre.remove(lock)
|
||||||
|
bpy.app.handlers.redo_pre.remove(unlock)
|
||||||
|
bpy.app.handlers.redo_post.remove(lock)
|
||||||
bpy.app.handlers.undo_post.remove(sanitize_deps_graph)
|
bpy.app.handlers.undo_post.remove(sanitize_deps_graph)
|
||||||
bpy.app.handlers.redo_post.remove(sanitize_deps_graph)
|
bpy.app.handlers.redo_post.remove(sanitize_deps_graph)
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ class ApplyTimer(Timer):
|
|||||||
def __init__(self, timeout=1, target_type=None):
|
def __init__(self, timeout=1, target_type=None):
|
||||||
self._type = target_type
|
self._type = target_type
|
||||||
super().__init__(timeout)
|
super().__init__(timeout)
|
||||||
self.id = target_type.__name__
|
self.id = target_type.__name__ if target_type else "ApplyTimer"
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
if session and session.state['STATE'] == STATE_ACTIVE:
|
if session and session.state['STATE'] == STATE_ACTIVE:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user