Skip to content

Commit 3e9d577

Browse files
author
Liam Hoflay
committed
Making all signal connections use partials rather than lambdas to work with katana
(cherry picked from commit c2153bb)
1 parent c616a0a commit 3e9d577

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

python/tk_multi_loader/loader_action_manager.py

Lines changed: 11 additions & 13 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
@@ -229,11 +230,8 @@ def get_actions_for_publishes(self, sg_data_list, ui_area):
229230
]
230231

231232
# Bind all the action params to a single invocation of the _execute_hook.
232-
a.triggered[()].connect(
233-
lambda qt_action=a, actions=actions: self._execute_hook(
234-
qt_action, actions
235-
)
236-
)
233+
cb = partial(self._execute_hook, a, actions)
234+
a.triggered[()].connect(cb)
237235
a.setData(actions)
238236
qt_actions.append(a)
239237

@@ -358,11 +356,8 @@ def get_actions_for_folder(self, sg_data):
358356
]
359357

360358
# Bind all the action params to a single invocation of the _execute_hook.
361-
a.triggered[()].connect(
362-
lambda qt_action=a, actions=actions: self._execute_hook(
363-
qt_action, actions
364-
)
365-
)
359+
cb = partial(self._execute_hook, a, actions)
360+
a.triggered[()].connect(cb)
366361
a.setData(actions)
367362
qt_actions.append(a)
368363

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

377373
sg = QtGui.QAction("Show details in Shotgun", None)
378-
sg.triggered[()].connect(lambda f=sg_data: self._show_in_sg(f))
374+
cb = partial(self._show_in_sg, sg_data)
375+
sg.triggered[()].connect(cb)
379376
qt_actions.append(sg)
380377

381378
sr = QtGui.QAction("Show in Media Center", None)
382-
sr.triggered[()].connect(lambda f=sg_data: self._show_in_sr(f))
379+
cb = partial(self._show_in_sr, sg_data)
380+
sr.triggered[()].connect(cb)
383381
qt_actions.append(sr)
384382

385383
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

@@ -68,7 +68,7 @@ def get_default_action_for_publish(self, sg_data, ui_area):
6868

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

7474
return action

0 commit comments

Comments
 (0)