fix: owning parent when a child is already owned (ex: duplicate linked)

This commit is contained in:
Swann
2020-10-21 14:15:42 +02:00
parent 7ee705332f
commit 804747c73b
4 changed files with 14 additions and 10 deletions

View File

@ -44,7 +44,7 @@ from . import environment
DEPENDENCIES = { DEPENDENCIES = {
("replication", '0.1.4'), ("replication", '0.1.5'),
} }

View File

@ -92,7 +92,6 @@ def load_driver(target_datablock, src_driver):
def get_datablock_from_uuid(uuid, default, ignore=[]): def get_datablock_from_uuid(uuid, default, ignore=[]):
if not uuid: if not uuid:
return default return default
for category in dir(bpy.data): for category in dir(bpy.data):
root = getattr(bpy.data, category) root = getattr(bpy.data, category)
if isinstance(root, Iterable) and category not in ignore: if isinstance(root, Iterable) and category not in ignore:
@ -123,7 +122,7 @@ class BlDatablock(ReplicatedDatablock):
# TODO: use is_library_indirect # TODO: use is_library_indirect
self.is_library = (instance and hasattr(instance, 'library') and self.is_library = (instance and hasattr(instance, 'library') and
instance.library) or \ instance.library) or \
(self.data and 'library' in self.data) (hasattr(self,'data') and self.data and 'library' in self.data)
if instance and hasattr(instance, 'uuid'): if instance and hasattr(instance, 'uuid'):
instance.uuid = self.uuid instance.uuid = self.uuid

View File

@ -171,7 +171,8 @@ class DynamicRightSelectTimer(Timer):
session.change_owner( session.change_owner(
node.uuid, node.uuid,
RP_COMMON, RP_COMMON,
recursive=recursive) ignore_warnings=True,
affect_dependencies=recursive)
except NonAuthorizedOperationError: except NonAuthorizedOperationError:
logging.warning(f"Not authorized to change {node} owner") logging.warning(f"Not authorized to change {node} owner")
@ -188,7 +189,8 @@ class DynamicRightSelectTimer(Timer):
session.change_owner( session.change_owner(
node.uuid, node.uuid,
settings.username, settings.username,
recursive=recursive) ignore_warnings=True,
affect_dependencies=recursive)
except NonAuthorizedOperationError: except NonAuthorizedOperationError:
logging.warning(f"Not authorized to change {node} owner") logging.warning(f"Not authorized to change {node} owner")
else: else:
@ -213,7 +215,8 @@ class DynamicRightSelectTimer(Timer):
session.change_owner( session.change_owner(
key, key,
RP_COMMON, RP_COMMON,
recursive=recursive) ignore_warnings=True,
affect_dependencies=recursive)
except NonAuthorizedOperationError: except NonAuthorizedOperationError:
logging.warning(f"Not authorized to change {key} owner") logging.warning(f"Not authorized to change {key} owner")

View File

@ -226,7 +226,8 @@ class SessionStartOperator(bpy.types.Operator):
except Exception as e: except Exception as e:
self.report({'ERROR'}, repr(e)) self.report({'ERROR'}, repr(e))
logging.error(f"Error: {e}") logging.error(f"Error: {e}")
import traceback
traceback.print_exc()
# Join a session # Join a session
else: else:
if not runtime_settings.admin: if not runtime_settings.admin:
@ -424,9 +425,10 @@ class SessionPropertyRightOperator(bpy.types.Operator):
runtime_settings = context.window_manager.session runtime_settings = context.window_manager.session
if session: if session:
session.change_owner(self.key, session.affect_dependencies(self.key,
runtime_settings.clients, runtime_settings.clients,
recursive=self.recursive) ignore_warnings=True,
affect_dependencies=self.recursive)
return {"FINISHED"} return {"FINISHED"}