Fix a crash inside ModelManagerInterface on Creator shutdown

Synchronize all the running futures on shutdown. It's enough
that all threads started by runAsync() just finish, without the
need for delivering the results of these futures to onFinished
handlers.

Fixes: QTCREATORBUG-25350
Change-Id: Iac5ae3834bb02ef0a77b063c59097471ec7e757d
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
This commit is contained in:
Jarek Kobus
2021-03-05 15:14:51 +01:00
parent fe7b5458eb
commit 54f3232f63
2 changed files with 4 additions and 2 deletions

View File

@@ -140,6 +140,7 @@ ModelManagerInterface::ModelManagerInterface(QObject *parent)
ModelManagerInterface::~ModelManagerInterface()
{
joinAllThreads(true);
m_cppQmlTypesUpdater.cancel();
m_cppQmlTypesUpdater.waitForFinished();
Q_ASSERT(g_instance == this);
@@ -1558,7 +1559,7 @@ void ModelManagerInterface::setDefaultVContext(const ViewerContext &vContext)
m_defaultVContexts[vContext.language] = vContext;
}
void ModelManagerInterface::joinAllThreads()
void ModelManagerInterface::joinAllThreads(bool cancelOnWait)
{
while (true) {
FutureSynchronizer futureSynchronizer;
@@ -1567,6 +1568,7 @@ void ModelManagerInterface::joinAllThreads()
futureSynchronizer = m_futureSynchronizer;
m_futureSynchronizer.clearFutures();
}
futureSynchronizer.setCancelOnWait(cancelOnWait);
if (futureSynchronizer.isEmpty())
return;
}

View File

@@ -244,7 +244,7 @@ protected:
void setDefaultProject(const ProjectInfo &pInfo, ProjectExplorer::Project *p);
private:
void joinAllThreads();
void joinAllThreads(bool cancelOnWait = false);
void iterateQrcFiles(ProjectExplorer::Project *project,
QrcResourceSelector resources,
const std::function<void(Utils::QrcParser::ConstPtr)> &callback);