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

Making all signal connections use partials rather than lambdas to wor… #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
24 changes: 11 additions & 13 deletions python/tk_multi_loader/loader_action_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import sgtk
import datetime
from functools import partial
import os
import sys
from sgtk.platform.qt import QtCore, QtGui
Expand Down Expand Up @@ -229,11 +230,8 @@ def get_actions_for_publishes(self, sg_data_list, ui_area):
]

# Bind all the action params to a single invocation of the _execute_hook.
a.triggered[()].connect(
lambda qt_action=a, actions=actions: self._execute_hook(
qt_action, actions
)
)
cb = partial(self._execute_hook, a, actions)
a.triggered[()].connect(cb)
a.setData(actions)
qt_actions.append(a)

Expand Down Expand Up @@ -358,11 +356,8 @@ def get_actions_for_folder(self, sg_data):
]

# Bind all the action params to a single invocation of the _execute_hook.
a.triggered[()].connect(
lambda qt_action=a, actions=actions: self._execute_hook(
qt_action, actions
)
)
cb = partial(self._execute_hook, a, actions)
a.triggered[()].connect(cb)
a.setData(actions)
qt_actions.append(a)

Expand All @@ -371,15 +366,18 @@ def get_actions_for_folder(self, sg_data):
# Add the action only when there are some paths.
if paths:
fs = QtGui.QAction("Show in the file system", None)
fs.triggered[()].connect(lambda f=paths: self._show_in_fs(f))
cb = partial(self._show_in_fs, paths)
fs.triggered[()].connect(cb)
qt_actions.append(fs)

sg = QtGui.QAction("Show details in Shotgun", None)
sg.triggered[()].connect(lambda f=sg_data: self._show_in_sg(f))
cb = partial(self._show_in_sg, sg_data)
sg.triggered[()].connect(cb)
qt_actions.append(sg)

sr = QtGui.QAction("Show in Media Center", None)
sr.triggered[()].connect(lambda f=sg_data: self._show_in_sr(f))
cb = partial(self._show_in_sr, sg_data)
sr.triggered[()].connect(cb)
qt_actions.append(sr)

return qt_actions
Expand Down
4 changes: 2 additions & 2 deletions python/tk_multi_loader/open_publish_action_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
A specialisation of the main ActionManager class for the open publish version of the
loader UI.
"""

from functools import partial
from sgtk.platform.qt import QtCore, QtGui
from .action_manager import ActionManager

Expand Down Expand Up @@ -68,7 +68,7 @@ def get_default_action_for_publish(self, sg_data, ui_area):

# connect the default action so that the default_action_triggered
# is emitted:
default_action_cb = lambda sg=sg_data: self.default_action_triggered.emit(sg)
default_action_cb = partial(self.default_action_triggered.emit, sg_data)
action.triggered[()].connect(default_action_cb)

return action
Expand Down