From 46e912ad24f472178563deedb97840d11d78c6b0 Mon Sep 17 00:00:00 2001 From: Daniel Teske Date: Thu, 3 Nov 2011 15:08:59 +0100 Subject: [PATCH] Appoutputpane sender() can't be used in a queued connection The bug was introduced in 97b4bcfa6c98a0a3a4dcc6dc6315513f27b7a976 Change-Id: Iec364a40ff748cd8f94f65e8fd22d4d71a5de5f4 Reviewed-by: hjk --- src/plugins/projectexplorer/appoutputpane.cpp | 18 ++++++++++++------ src/plugins/projectexplorer/appoutputpane.h | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/plugins/projectexplorer/appoutputpane.cpp b/src/plugins/projectexplorer/appoutputpane.cpp index bcfebb34edd..e5caea75d1b 100644 --- a/src/plugins/projectexplorer/appoutputpane.cpp +++ b/src/plugins/projectexplorer/appoutputpane.cpp @@ -301,7 +301,7 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc) connect(rc, SIGNAL(started()), this, SLOT(slotRunControlStarted())); connect(rc, SIGNAL(finished()), - this, SLOT(slotRunControlFinished()), Qt::QueuedConnection); + this, SLOT(slotRunControlFinished())); connect(rc, SIGNAL(applicationProcessHandleChanged()), this, SLOT(enableButtons())); connect(rc, SIGNAL(appendMessage(ProjectExplorer::RunControl*,QString,Utils::OutputFormat)), @@ -541,8 +541,14 @@ void AppOutputPane::slotRunControlStarted() void AppOutputPane::slotRunControlFinished() { - RunControl *senderRunControl = qobject_cast(sender()); - const int senderIndex = indexOf(senderRunControl); + ProjectExplorer::RunControl *rc = qobject_cast(sender()); + QMetaObject::invokeMethod(this, "slotRunControlFinished2", Qt::QueuedConnection, + Q_ARG(ProjectExplorer::RunControl *, rc)); +} + +void AppOutputPane::slotRunControlFinished2(RunControl *sender) +{ + const int senderIndex = indexOf(sender); QTC_ASSERT(senderIndex != -1, return; ) @@ -550,17 +556,17 @@ void AppOutputPane::slotRunControlFinished() RunControl *current = currentRunControl(); if (debug) - qDebug() << "OutputPane::runControlFinished" << senderRunControl << senderIndex + qDebug() << "OutputPane::runControlFinished" << sender << senderIndex << " current " << current << m_runControlTabs.size(); - if (current && current == sender()) + if (current && current == sender) enableButtons(current, false); // RunControl::isRunning() cannot be trusted in signal handler. // Check for asynchronous close. Close the tab. if (m_runControlTabs.at(senderIndex).asyncClosing) closeTab(tabWidgetIndexOf(senderIndex), CloseTabNoPrompt); - emit runControlFinished(senderRunControl); + emit runControlFinished(sender); if (!isRunning()) emit allRunControlsFinished(); diff --git a/src/plugins/projectexplorer/appoutputpane.h b/src/plugins/projectexplorer/appoutputpane.h index b521c17af6b..968aec6e6d9 100644 --- a/src/plugins/projectexplorer/appoutputpane.h +++ b/src/plugins/projectexplorer/appoutputpane.h @@ -107,6 +107,7 @@ private slots: void contextMenuRequested(const QPoint &pos, int index); void slotRunControlStarted(); void slotRunControlFinished(); + void slotRunControlFinished2(RunControl *sender); void aboutToUnloadSession(); void updateFromSettings();