From ddbfdb6f3f04f21305cfef56783cf1b451bcab9a Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 19 Jul 2023 09:47:43 +0200 Subject: [PATCH] ProjectExplorer: Fix 10 seconds hang on shutdown Delete the RunControl directly when it's not running. Do it in two cases: when tab is closed and when tab is reused with a new RunControl instance. In other case, queue the call to initiateStop, so that any possible deleteLater() is called when the nested event loop of the shutdown is already spinning. It looks like the amended changes introduced the hang when compiled against Qt 6.5. When compiled against Qt 6.4 the regression doesn't occur. The regression is caused by 449b45ff34ce4a45e5d6a24967566f69f43ebbb6. Amends c1f6d7044589f7842d19fc7b44574152ce72a20f Amends 6e16512eba2c39baa714fa253843b2171ba24f47 Change-Id: Icb3ba757f32bccb3daae675b2eb516f75b84530a Reviewed-by: hjk Reviewed-by: Eike Ziller Reviewed-by: Qt CI Bot --- src/plugins/projectexplorer/appoutputpane.cpp | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/plugins/projectexplorer/appoutputpane.cpp b/src/plugins/projectexplorer/appoutputpane.cpp index c69aeaf828c..2255d96b5e9 100644 --- a/src/plugins/projectexplorer/appoutputpane.cpp +++ b/src/plugins/projectexplorer/appoutputpane.cpp @@ -407,10 +407,9 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc) }); if (tab != m_runControlTabs.end()) { // Reuse this tab - if (tab->runControl) { - tab->runControl->setAutoDeleteOnStop(true); - tab->runControl->initiateStop(); - } + if (tab->runControl) + delete tab->runControl; + tab->runControl = rc; tab->window->reset(); rc->setupFormatter(tab->window->outputFormatter()); @@ -645,12 +644,18 @@ void AppOutputPane::closeTab(int tabIndex, CloseTabMode closeTabMode) m_tabWidget->removeTab(tabIndex); delete window; + Utils::erase(m_runControlTabs, [runControl](const RunControlTab &t) { + return t.runControl == runControl; }); if (runControl) { - runControl->setAutoDeleteOnStop(true); - runControl->initiateStop(); + if (runControl->isRunning()) { + QMetaObject::invokeMethod(runControl, [runControl] { + runControl->setAutoDeleteOnStop(true); + runControl->initiateStop(); + }, Qt::QueuedConnection); + } else { + delete runControl; + } } - Utils::erase(m_runControlTabs, [tab](const RunControlTab &t) { - return t.runControl == tab->runControl; }); updateCloseActions(); setFilteringEnabled(m_tabWidget->count() > 0);