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 c1f6d70445
Amends 6e16512eba

Change-Id: Icb3ba757f32bccb3daae675b2eb516f75b84530a
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Jarek Kobus
2023-07-19 09:47:43 +02:00
parent 323e94c2fa
commit ddbfdb6f3f

View File

@@ -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);