diff --git a/.gitlab/ci/deploy.gitlab-ci.yml b/.gitlab/ci/deploy.gitlab-ci.yml index a5e9778..580bd05 100644 --- a/.gitlab/ci/deploy.gitlab-ci.yml +++ b/.gitlab/ci/deploy.gitlab-ci.yml @@ -21,4 +21,5 @@ deploy: only: refs: - master - - develop \ No newline at end of file + - develop + - 132-fix-undo-edit-last-operation-redo-handling-2 \ No newline at end of file diff --git a/multi_user/__init__.py b/multi_user/__init__.py index 9d8e560..7410d83 100644 --- a/multi_user/__init__.py +++ b/multi_user/__init__.py @@ -19,7 +19,7 @@ bl_info = { "name": "Multi-User", "author": "Swann Martinez", - "version": (0, 2, 0), + "version": (0, 3, 0), "description": "Enable real-time collaborative workflow inside blender", "blender": (2, 82, 0), "location": "3D View > Sidebar > Multi-User tab", diff --git a/multi_user/bl_types/bl_collection.py b/multi_user/bl_types/bl_collection.py index 7b78989..c9874e4 100644 --- a/multi_user/bl_types/bl_collection.py +++ b/multi_user/bl_types/bl_collection.py @@ -114,6 +114,10 @@ class BlCollection(BlDatablock): # Link childrens load_collection_childrens(data['children'], target) + # FIXME: Find a better way after the replication big refacotoring + # Keep other user from deleting collection object by flushing their history + utils.flush_history() + def _dump_implementation(self, data, instance=None): assert(instance) diff --git a/multi_user/bl_types/bl_datablock.py b/multi_user/bl_types/bl_datablock.py index d2e36fd..d10cbe4 100644 --- a/multi_user/bl_types/bl_datablock.py +++ b/multi_user/bl_types/bl_datablock.py @@ -148,12 +148,6 @@ class BlDatablock(ReplicatedDatablock): logging.debug(f"Constructing {name}") datablock_ref = self._construct(data=self.data) - try: - for i in range(bpy.context.preferences.edit.undo_steps+1): - bpy.ops.ed.undo_push(message="Multiuser history flush") - except RuntimeError: - logging.error("Fail to overwrite history") - if datablock_ref is not None: setattr(datablock_ref, 'uuid', self.uuid) self.instance = datablock_ref diff --git a/multi_user/bl_types/bl_scene.py b/multi_user/bl_types/bl_scene.py index 575f515..df7e9a6 100644 --- a/multi_user/bl_types/bl_scene.py +++ b/multi_user/bl_types/bl_scene.py @@ -28,6 +28,7 @@ from .bl_collection import (dump_collection_children, dump_collection_objects, resolve_collection_dependencies) from .bl_datablock import BlDatablock from .dump_anything import Dumper, Loader +from ..utils import flush_history RENDER_SETTINGS = [ 'dither_intensity', @@ -328,6 +329,10 @@ class BlScene(BlDatablock): 'view_settings']['curve_mapping']['black_level'] target.view_settings.curve_mapping.update() + # FIXME: Find a better way after the replication big refacotoring + # Keep other user from deleting collection object by flushing their history + flush_history() + def _dump_implementation(self, data, instance=None): assert(instance) diff --git a/multi_user/operators.py b/multi_user/operators.py index 1cae1cf..942aea0 100644 --- a/multi_user/operators.py +++ b/multi_user/operators.py @@ -99,8 +99,7 @@ def initialize_session(): 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") + utils.flush_history() @session_callback('on_exit') diff --git a/multi_user/utils.py b/multi_user/utils.py index 57ed532..8667b2d 100644 --- a/multi_user/utils.py +++ b/multi_user/utils.py @@ -65,6 +65,15 @@ def get_datablock_users(datablock): return users +def flush_history(): + try: + logging.info("Flushing history") + for i in range(bpy.context.preferences.edit.undo_steps+1): + bpy.ops.ed.undo_push(message="Multiuser history flush") + except RuntimeError: + logging.error("Fail to overwrite history") + + def get_state_str(state): state_str = 'UNKOWN' if state == STATE_WAITING: