aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/appoutputpane.cpp
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2022-07-20 16:11:23 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2022-07-21 10:11:05 +0000
commitffb282eb4725fb58121ee586cc108866d5d7f583 (patch)
treec457e6c3d3f7d356719b4227ad253309d9cc2cff /src/plugins/projectexplorer/appoutputpane.cpp
parentbbb4966cd734ea6c34455e091af0d110ea86b6e9 (diff)
AppOutputPane: Avoid using sender()
Change-Id: Id24f38d376de66c0d6e91ed37165506c78e33dde Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Diffstat (limited to 'src/plugins/projectexplorer/appoutputpane.cpp')
-rw-r--r--src/plugins/projectexplorer/appoutputpane.cpp50
1 files changed, 21 insertions, 29 deletions
diff --git a/src/plugins/projectexplorer/appoutputpane.cpp b/src/plugins/projectexplorer/appoutputpane.cpp
index 11674508b0..4f6304a3c4 100644
--- a/src/plugins/projectexplorer/appoutputpane.cpp
+++ b/src/plugins/projectexplorer/appoutputpane.cpp
@@ -393,12 +393,23 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
{
QTC_ASSERT(rc, return);
- connect(rc, &RunControl::aboutToStart,
- this, &AppOutputPane::slotRunControlChanged);
- connect(rc, &RunControl::started,
- this, &AppOutputPane::slotRunControlChanged);
- connect(rc, &RunControl::stopped,
- this, &AppOutputPane::slotRunControlFinished);
+ auto runControlChanged = [this, rc] {
+ RunControl *current = currentRunControl();
+ if (current && current == rc)
+ enableButtons(current); // RunControl::isRunning() cannot be trusted in signal handler.
+ };
+
+ connect(rc, &RunControl::aboutToStart, this, runControlChanged);
+ connect(rc, &RunControl::started, this, runControlChanged);
+ connect(rc, &RunControl::stopped, this, [this, rc] {
+ QTimer::singleShot(0, this, [this, rc] { runControlFinished(rc); });
+ for (const RunControlTab &t : qAsConst(m_runControlTabs)) {
+ if (t.runControl == rc) {
+ t.window->flush();
+ break;
+ }
+ }
+ });
connect(rc, &RunControl::applicationProcessHandleChanged,
this, &AppOutputPane::enableDefaultButtons);
connect(rc, &RunControl::appendMessage,
@@ -765,28 +776,9 @@ void AppOutputPane::contextMenuRequested(const QPoint &pos, int index)
}
}
-void AppOutputPane::slotRunControlChanged()
-{
- RunControl *current = currentRunControl();
- if (current && current == sender())
- enableButtons(current); // RunControl::isRunning() cannot be trusted in signal handler.
-}
-
-void AppOutputPane::slotRunControlFinished()
-{
- auto *rc = qobject_cast<RunControl *>(sender());
- QTimer::singleShot(0, this, [this, rc]() { slotRunControlFinished2(rc); });
- for (const RunControlTab &t : qAsConst(m_runControlTabs)) {
- if (t.runControl == rc) {
- t.window->flush();
- break;
- }
- }
-}
-
-void AppOutputPane::slotRunControlFinished2(RunControl *sender)
+void AppOutputPane::runControlFinished(RunControl *runControl)
{
- const RunControlTab * const tab = tabFor(sender);
+ const RunControlTab * const tab = tabFor(runControl);
// This slot is queued, so the stop() call in closeTab might lead to this slot, after closeTab already cleaned up
if (!tab)
@@ -795,11 +787,11 @@ void AppOutputPane::slotRunControlFinished2(RunControl *sender)
// Enable buttons for current
RunControl *current = currentRunControl();
- qCDebug(appOutputLog) << "AppOutputPane::runControlFinished" << sender
+ qCDebug(appOutputLog) << "AppOutputPane::runControlFinished" << runControl
<< m_tabWidget->indexOf(tab->window)
<< "current" << current << m_runControlTabs.size();
- if (current && current == sender)
+ if (current && current == runControl)
enableButtons(current);
ProjectExplorerPlugin::updateRunActions();