mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 22:02:15 +01:00
moved update and remove logic to create context
This commit is contained in:
parent
f4c3075503
commit
f372dcfe4e
2 changed files with 16 additions and 9 deletions
|
|
@ -558,6 +558,19 @@ class CreateContext:
|
|||
|
||||
self.instances = instances
|
||||
|
||||
def save_instance_changes(self):
|
||||
update_list = []
|
||||
for instance in self.instances:
|
||||
instance_changes = instance.changes()
|
||||
if instance_changes:
|
||||
update_list.append((instance, instance_changes))
|
||||
|
||||
if update_list:
|
||||
self.host.update_instances(update_list)
|
||||
|
||||
def remove_instances(self, instances):
|
||||
self.host.remove_instances(instances)
|
||||
|
||||
def _get_publish_plugins_with_attr_for_family(self, family):
|
||||
if family not in self._attr_plugins_by_family:
|
||||
import pyblish.logic
|
||||
|
|
|
|||
|
|
@ -519,23 +519,17 @@ class PublisherController:
|
|||
def create(self, family, subset_name, instance_data, options):
|
||||
# QUESTION Force to return instances or call `list_instances` on each
|
||||
# creation? (`list_instances` may slow down...)
|
||||
# WARNING changes done before creation will be lost
|
||||
creator = self.creators[family]
|
||||
creator.create(subset_name, instance_data, options)
|
||||
|
||||
self._reset_instances()
|
||||
|
||||
def save_instance_changes(self):
|
||||
update_list = []
|
||||
for instance in self.instances:
|
||||
instance_changes = instance.changes()
|
||||
if instance_changes:
|
||||
update_list.append((instance, instance_changes))
|
||||
|
||||
if update_list:
|
||||
self.host.update_instances(update_list)
|
||||
self.create_context.save_instance_changes()
|
||||
|
||||
def remove_instances(self, instances):
|
||||
self.host.remove_instances(instances)
|
||||
self.create_context.remove_instances(instances)
|
||||
|
||||
self._reset_instances()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue