CppTools: Fix thread-unsafe call to MessageManager::write()

The Preprocessor running in a worker thread can call this function.

Fixes: QTCREATORBUG-21481
Change-Id: I4970379fbabae23cfa3d7c1222e81a4ae8c3e6ad
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Nikolai Kosjar
2018-11-15 15:08:44 +01:00
parent 03bda2aee8
commit 7ef2dccff8

View File

@@ -258,7 +258,20 @@ bool fileSizeExceedsLimit(const QFileInfo &fileInfo, int sizeLimitInMb)
"CppIndexer", "CppIndexer",
"C++ Indexer: Skipping file \"%1\" because it is too big.") "C++ Indexer: Skipping file \"%1\" because it is too big.")
.arg(absoluteFilePath); .arg(absoluteFilePath);
Core::MessageManager::write(msg, Core::MessageManager::Silent);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(Core::MessageManager::instance(), [msg]() {
Core::MessageManager::write(msg, Core::MessageManager::Silent);
});
#else
QMetaObject::invokeMethod(Core::MessageManager::instance(),
"write",
Qt::QueuedConnection,
Q_ARG(QString, msg),
Q_ARG(Core::MessageManager::PrintToOutputPaneFlags,
Core::MessageManager::Silent));
#endif
qWarning().noquote() << msg; qWarning().noquote() << msg;
return true; return true;
} }