Core: Handle async log category init

If a log category is first used by a different thread than the main
thread, we need to make sure that we dispatch the call into the
main thread ourselves.

Change-Id: I0908366b254649f30a1d18cb4e0da4a7e3988dcc
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-10-30 08:25:29 +01:00
parent 53931b18ad
commit ee3e6376f0

View File

@@ -95,6 +95,12 @@ private:
void onFilter(QLoggingCategory *category)
{
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(
this, [category, this] { onFilter(category); }, Qt::QueuedConnection);
return;
}
if (!m_categories.contains(category)) {
m_categories.append(category);
emit newLogCategory(category);