Skip to content

Commit

Permalink
Merge pull request #355 from davidlatwe/fix-targets
Browse files Browse the repository at this point in the history
Fix registered targets lost when re-launching on existed server
  • Loading branch information
davidlatwe authored Feb 11, 2020
2 parents e0a9015 + 839b1d9 commit 692965a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions pyblish_qml/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Application(QtGui.QGuiApplication):
inFocused = QtCore.Signal()
outFocused = QtCore.Signal()

def __init__(self, source, targets=[]):
def __init__(self, source, targets=None):
super(Application, self).__init__(sys.argv)

self.setWindowIcon(QtGui.QIcon(ICON_PATH))
Expand Down Expand Up @@ -277,7 +277,7 @@ def _listen():
thread.start()


def main(demo=False, aschild=False, targets=[]):
def main(demo=False, aschild=False, targets=None):
"""Start the Qt-runtime and show the window
Arguments:
Expand Down
7 changes: 4 additions & 3 deletions pyblish_qml/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ class Controller(QtCore.QObject):
resultModel = qtproperty(lambda self: self.data["models"]["result"])
resultProxy = qtproperty(lambda self: self.data["proxies"]["result"])

def __init__(self, host, parent=None, targets=[]):
def __init__(self, host, parent=None, targets=None):
super(Controller, self).__init__(parent)

# Connection to host
self.host = host

self.targets = targets
self.targets = targets or []

self.data = {
"models": {
Expand Down Expand Up @@ -994,7 +994,7 @@ def on_finished():

util.defer(get_data, callback=on_data_received)

def run(self, plugins, context, callback=None, callback_args=[]):
def run(self, plugins, context, callback=None, callback_args=None):
"""Commence asynchronous tasks
This method runs through the provided `plugins` in
Expand All @@ -1011,6 +1011,7 @@ def run(self, plugins, context, callback=None, callback_args=[]):
callback_args (list, optional): Arguments passed to callback
"""
callback_args = callback_args or []

# if "ready" not in self.states:
# return self.error.emit("Not ready")
Expand Down
10 changes: 8 additions & 2 deletions pyblish_qml/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def uninstall():


def show(parent=None,
targets=[],
targets=None,
modal=None,
auto_publish=False,
auto_validate=False):
Expand All @@ -97,6 +97,12 @@ def show(parent=None,
if modal is None:
modal = bool(os.environ.get("PYBLISH_QML_MODAL", False))

if not targets:
# If no targets are passed to pyblish-qml, we assume that we want the
# default target and the registered targets. This is to facilitate
# getting all plugins on pyblish_qml.show().
targets = ["default"] + pyblish.api.registered_targets()

# Automatically install if not already installed.
install(modal)

Expand All @@ -110,7 +116,7 @@ def show(parent=None,
proxy = ipc.server.Proxy(server)

try:
# Update target
# Update targets
proxy.target(targets)
proxy.show(show_settings)
return server
Expand Down
9 changes: 1 addition & 8 deletions pyblish_qml/ipc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(self,
service,
python=None,
pyqt5=None,
targets=[],
targets=None,
modal=False,
environ=None):

Expand Down Expand Up @@ -201,14 +201,7 @@ def __init__(self,
# from opening an external terminal window.
kwargs["creationflags"] = CREATE_NO_WINDOW

# If no targets are passed to pyblish-qml, we assume that we want the
# default target and the registered targets. This is to facilitate
# getting all plugins on pyblish_qml.show().
import pyblish.api
if not targets:
targets = ["default"] + pyblish.api.registered_targets()
print("Targets: {0}".format(", ".join(targets)))

kwargs["args"].append("--targets")
kwargs["args"].extend(targets)

Expand Down

0 comments on commit 692965a

Please sign in to comment.