feat: one apply timer for all

This commit is contained in:
Swann Martinez
2020-03-05 15:38:20 +01:00
parent 50d14e663e
commit adeb694b2d
3 changed files with 8 additions and 10 deletions

View File

@ -59,21 +59,20 @@ class Timer(Delayable):
class ApplyTimer(Timer): class ApplyTimer(Timer):
def __init__(self, timout=1, target_type=None): def __init__(self, timout=1):
self._type = target_type
super().__init__(timout) super().__init__(timout)
def execute(self): def execute(self):
client = operators.client client = operators.client
if client and client.state['STATE'] == STATE_ACTIVE: if client and client.state['STATE'] == STATE_ACTIVE:
nodes = client.list(filter=self._type) nodes = client.list()
for node in nodes: for node in nodes:
node_ref = client.get(uuid=node) node_ref = client.get(uuid=node)
if node_ref.state == FETCHED: if node_ref.state == FETCHED:
try: try:
client.apply(node) client.apply(node, force=True)
except Exception as e: except Exception as e:
logger.error( logger.error(
"fail to apply {}: {}".format(node_ref.uuid, e)) "fail to apply {}: {}".format(node_ref.uuid, e))

View File

@ -87,16 +87,13 @@ class SessionStartOperator(bpy.types.Operator):
timer=type_local_config.bl_delay_refresh, timer=type_local_config.bl_delay_refresh,
automatic=type_local_config.auto_push) automatic=type_local_config.auto_push)
if type_local_config.bl_delay_apply > 0:
delayables.append(delayable.ApplyTimer(
timout=type_local_config.bl_delay_apply,
target_type=type_module_class))
client = Session( client = Session(
factory=bpy_factory, factory=bpy_factory,
python_path=bpy.app.binary_path_python, python_path=bpy.app.binary_path_python,
default_strategy=settings.right_strategy) default_strategy=settings.right_strategy)
delayables.append(delayable.ApplyTimer())
# Host a session # Host a session
if self.host: if self.host:
# Scene setup # Scene setup
@ -500,6 +497,8 @@ def depsgraph_evaluation(scene):
# Avoid slow geometry update # Avoid slow geometry update
if 'EDIT' in context.mode: if 'EDIT' in context.mode:
break break
logger.error(node.data['name'])
client.stash(node.uuid) client.stash(node.uuid)
else: else:
# Distant update # Distant update