Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix registered targets lost when re-launching on existed server #355

Merged
merged 3 commits into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyblish_qml/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Application(QtGui.QGuiApplication):
inFocused = QtCore.pyqtSignal()
outFocused = QtCore.pyqtSignal()

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 @@ -281,7 +281,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 @@ -984,7 +984,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 @@ -1001,6 +1001,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