Appoutputpane sender() can't be used in a queued connection

The bug was introduced in 97b4bcfa6c

Change-Id: Iec364a40ff748cd8f94f65e8fd22d4d71a5de5f4
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Daniel Teske
2011-11-03 15:08:59 +01:00
committed by hjk
parent dea23cd73e
commit 46e912ad24
2 changed files with 13 additions and 6 deletions

View File

@@ -301,7 +301,7 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
connect(rc, SIGNAL(started()), connect(rc, SIGNAL(started()),
this, SLOT(slotRunControlStarted())); this, SLOT(slotRunControlStarted()));
connect(rc, SIGNAL(finished()), connect(rc, SIGNAL(finished()),
this, SLOT(slotRunControlFinished()), Qt::QueuedConnection); this, SLOT(slotRunControlFinished()));
connect(rc, SIGNAL(applicationProcessHandleChanged()), connect(rc, SIGNAL(applicationProcessHandleChanged()),
this, SLOT(enableButtons())); this, SLOT(enableButtons()));
connect(rc, SIGNAL(appendMessage(ProjectExplorer::RunControl*,QString,Utils::OutputFormat)), connect(rc, SIGNAL(appendMessage(ProjectExplorer::RunControl*,QString,Utils::OutputFormat)),
@@ -541,8 +541,14 @@ void AppOutputPane::slotRunControlStarted()
void AppOutputPane::slotRunControlFinished() void AppOutputPane::slotRunControlFinished()
{ {
RunControl *senderRunControl = qobject_cast<RunControl *>(sender()); ProjectExplorer::RunControl *rc = qobject_cast<RunControl *>(sender());
const int senderIndex = indexOf(senderRunControl); 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; ) QTC_ASSERT(senderIndex != -1, return; )
@@ -550,17 +556,17 @@ void AppOutputPane::slotRunControlFinished()
RunControl *current = currentRunControl(); RunControl *current = currentRunControl();
if (debug) if (debug)
qDebug() << "OutputPane::runControlFinished" << senderRunControl << senderIndex qDebug() << "OutputPane::runControlFinished" << sender << senderIndex
<< " current " << current << m_runControlTabs.size(); << " current " << current << m_runControlTabs.size();
if (current && current == sender()) if (current && current == sender)
enableButtons(current, false); // RunControl::isRunning() cannot be trusted in signal handler. enableButtons(current, false); // RunControl::isRunning() cannot be trusted in signal handler.
// Check for asynchronous close. Close the tab. // Check for asynchronous close. Close the tab.
if (m_runControlTabs.at(senderIndex).asyncClosing) if (m_runControlTabs.at(senderIndex).asyncClosing)
closeTab(tabWidgetIndexOf(senderIndex), CloseTabNoPrompt); closeTab(tabWidgetIndexOf(senderIndex), CloseTabNoPrompt);
emit runControlFinished(senderRunControl); emit runControlFinished(sender);
if (!isRunning()) if (!isRunning())
emit allRunControlsFinished(); emit allRunControlsFinished();

View File

@@ -107,6 +107,7 @@ private slots:
void contextMenuRequested(const QPoint &pos, int index); void contextMenuRequested(const QPoint &pos, int index);
void slotRunControlStarted(); void slotRunControlStarted();
void slotRunControlFinished(); void slotRunControlFinished();
void slotRunControlFinished2(RunControl *sender);
void aboutToUnloadSession(); void aboutToUnloadSession();
void updateFromSettings(); void updateFromSettings();