feat: flush history on collection and scene update only

feat: enable deploy for undo branch
This commit is contained in:
Swann
2020-12-23 18:46:29 +01:00
parent 2f4e30f432
commit 3d9da73ab0
7 changed files with 22 additions and 10 deletions

View File

@ -21,4 +21,5 @@ deploy:
only: only:
refs: refs:
- master - master
- develop - develop
- 132-fix-undo-edit-last-operation-redo-handling-2

View File

@ -19,7 +19,7 @@
bl_info = { bl_info = {
"name": "Multi-User", "name": "Multi-User",
"author": "Swann Martinez", "author": "Swann Martinez",
"version": (0, 2, 0), "version": (0, 3, 0),
"description": "Enable real-time collaborative workflow inside blender", "description": "Enable real-time collaborative workflow inside blender",
"blender": (2, 82, 0), "blender": (2, 82, 0),
"location": "3D View > Sidebar > Multi-User tab", "location": "3D View > Sidebar > Multi-User tab",

View File

@ -114,6 +114,10 @@ class BlCollection(BlDatablock):
# Link childrens # Link childrens
load_collection_childrens(data['children'], target) 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): def _dump_implementation(self, data, instance=None):
assert(instance) assert(instance)

View File

@ -148,12 +148,6 @@ class BlDatablock(ReplicatedDatablock):
logging.debug(f"Constructing {name}") logging.debug(f"Constructing {name}")
datablock_ref = self._construct(data=self.data) 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: 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

View File

@ -28,6 +28,7 @@ from .bl_collection import (dump_collection_children, dump_collection_objects,
resolve_collection_dependencies) resolve_collection_dependencies)
from .bl_datablock import BlDatablock from .bl_datablock import BlDatablock
from .dump_anything import Dumper, Loader from .dump_anything import Dumper, Loader
from ..utils import flush_history
RENDER_SETTINGS = [ RENDER_SETTINGS = [
'dither_intensity', 'dither_intensity',
@ -328,6 +329,10 @@ class BlScene(BlDatablock):
'view_settings']['curve_mapping']['black_level'] 'view_settings']['curve_mapping']['black_level']
target.view_settings.curve_mapping.update() 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): def _dump_implementation(self, data, instance=None):
assert(instance) assert(instance)

View File

@ -99,8 +99,7 @@ def initialize_session():
bpy.ops.session.apply_armature_operator('INVOKE_DEFAULT') bpy.ops.session.apply_armature_operator('INVOKE_DEFAULT')
# Step 0: Clearing history # Step 0: Clearing history
for i in range(bpy.context.preferences.edit.undo_steps+1): utils.flush_history()
bpy.ops.ed.undo_push(message="Multiuser history flush")
@session_callback('on_exit') @session_callback('on_exit')

View File

@ -65,6 +65,15 @@ def get_datablock_users(datablock):
return users 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): def get_state_str(state):
state_str = 'UNKOWN' state_str = 'UNKOWN'
if state == STATE_WAITING: if state == STATE_WAITING: