Skip to content

Commit

Permalink
Making all signal connections use partials rather than lambdas to wor…
Browse files Browse the repository at this point in the history
…k with katana
  • Loading branch information
Liam Hoflay committed Jun 5, 2019
1 parent 0eea553 commit c2153bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 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 @@ -219,9 +220,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 @@ -344,9 +344,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 @@ -355,15 +354,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 @@ -67,7 +67,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

0 comments on commit c2153bb

Please sign in to comment.