Core: Correct log view thread handling

Fixes a crash when log messages are received from
multiple threads.

Fixes: QTCREATORBUG-30444
Change-Id: I51c78656da1dd30bcb51a801083d1714e474d8e5
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Christian Stenger
2024-02-27 08:27:06 +01:00
parent e95ad3778f
commit 4dcba2ad25

View File

@@ -559,10 +559,16 @@ private:
const QString timestamp = QDateTime::currentDateTime().toString("HH:mm:ss.zzz"); const QString timestamp = QDateTime::currentDateTime().toString("HH:mm:ss.zzz");
if (rowCount() >= 1000000) // limit log to 1000000 items auto append = [this, timestamp, type, category, msg] {
destroyItem(itemForIndex(index(0, 0))); if (rowCount() >= 1000000) // limit log to 1000000 items
destroyItem(itemForIndex(index(0, 0)));
appendItem(LogEntry{timestamp, messageTypeToString(type), category, msg});
};
appendItem(LogEntry{timestamp, messageTypeToString(type), category, msg}); if (QThread::currentThread() != thread())
QMetaObject::invokeMethod(this, append, Qt::QueuedConnection);
else
append();
} }
private: private: