diff --git a/pyblish_qml/control.py b/pyblish_qml/control.py index 219e3538..1db5cecb 100644 --- a/pyblish_qml/control.py +++ b/pyblish_qml/control.py @@ -305,7 +305,7 @@ def iterator(self, plugins, context): "ordersWithError": set() } - for plug, instance in iterator(plugins, context): + for plug, instance in pyblish.logic.Iterator(plugins, context): state["nextOrder"] = plug.order @@ -571,6 +571,11 @@ def __toggle_item(self, model, index): new_value=new_value, old_value=old_value) + # Update the plugin's active state so it processes correctly (#218) + plugin = next(plugin for plugin in self.host.cached_discover if + plugin.id == item.id) + plugin.active = new_value + if item.itemType == 'instance': self.host.emit("instanceToggled", instance=item.id, @@ -687,12 +692,23 @@ def reset(self): def on_finished(plugins, context): # Compute compatibility for plugin in self.data["models"]["item"].plugins: + if plugin.instanceEnabled: - instances = pyblish.logic.instances_by_plugin(context, - plugin) - plugin.compatibleInstances = list(i.id for i in instances) + required = pyblish.logic.instances_by_plugin(context, + plugin) else: - plugin.compatibleInstances = [context.id] + # A ContextPlugin without wildcard is only compatible + # when instance is present with correct family, see issue: + # pyblish-base/#250 + # todo: introduce backwards compatibility + has_wildcard = "*" in plugin.families + if has_wildcard: + required = [context] + else: + required = pyblish.logic.instances_by_plugin(context, + plugin) + + plugin.compatibleInstances = [i.id for i in required] self.data["models"]["item"].reorder(context) @@ -1023,27 +1039,3 @@ def on_finished(): # Reset state util.async(lambda: next(iterator), callback=on_next) - - -def iterator(plugins, context): - """An iterator for plug-in and instance pairs""" - test = pyblish.logic.registered_test() - state = { - "nextOrder": None, - "ordersWithError": set() - } - - for plugin in plugins: - state["nextOrder"] = plugin.order - - message = test(**state) - if message: - raise StopIteration("Stopped due to %s" % message) - - instances = pyblish.api.instances_by_plugin(context, plugin) - if plugin.__instanceEnabled__: - for instance in instances: - yield plugin, instance - - else: - yield plugin, None