Skip to content

Commit c2153bb

Browse files
author
Liam Hoflay
committed
Making all signal connections use partials rather than lambdas to work with katana
1 parent 0eea553 commit c2153bb

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

python/tk_multi_loader/loader_action_manager.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import sgtk
1212
import datetime
13+
from functools import partial
1314
import os
1415
import sys
1516
from sgtk.platform.qt import QtCore, QtGui
@@ -219,9 +220,8 @@ def get_actions_for_publishes(self, sg_data_list, ui_area):
219220
]
220221

221222
# Bind all the action params to a single invocation of the _execute_hook.
222-
a.triggered[()].connect(
223-
lambda qt_action=a, actions=actions: self._execute_hook(qt_action, actions)
224-
)
223+
cb = partial(self._execute_hook, a, actions)
224+
a.triggered[()].connect(cb)
225225
a.setData(actions)
226226
qt_actions.append(a)
227227

@@ -344,9 +344,8 @@ def get_actions_for_folder(self, sg_data):
344344
]
345345

346346
# Bind all the action params to a single invocation of the _execute_hook.
347-
a.triggered[()].connect(
348-
lambda qt_action=a, actions=actions: self._execute_hook(qt_action, actions)
349-
)
347+
cb = partial(self._execute_hook, a, actions)
348+
a.triggered[()].connect(cb)
350349
a.setData(actions)
351350
qt_actions.append(a)
352351

@@ -355,15 +354,18 @@ def get_actions_for_folder(self, sg_data):
355354
# Add the action only when there are some paths.
356355
if paths:
357356
fs = QtGui.QAction("Show in the file system", None)
358-
fs.triggered[()].connect(lambda f=paths: self._show_in_fs(f))
357+
cb = partial(self._show_in_fs, paths)
358+
fs.triggered[()].connect(cb)
359359
qt_actions.append(fs)
360360

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

365366
sr = QtGui.QAction("Show in Media Center", None)
366-
sr.triggered[()].connect(lambda f=sg_data: self._show_in_sr(f))
367+
cb = partial(self._show_in_sr, sg_data)
368+
sr.triggered[()].connect(cb)
367369
qt_actions.append(sr)
368370

369371
return qt_actions

python/tk_multi_loader/open_publish_action_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
A specialisation of the main ActionManager class for the open publish version of the
1313
loader UI.
1414
"""
15-
15+
from functools import partial
1616
from sgtk.platform.qt import QtCore, QtGui
1717
from .action_manager import ActionManager
1818

@@ -67,7 +67,7 @@ def get_default_action_for_publish(self, sg_data, ui_area):
6767

6868
# connect the default action so that the default_action_triggered
6969
# is emitted:
70-
default_action_cb = lambda sg=sg_data: self.default_action_triggered.emit(sg)
70+
default_action_cb = partial(self.default_action_triggered.emit, sg_data)
7171
action.triggered[()].connect(default_action_cb)
7272

7373
return action

0 commit comments

Comments
 (0)