forked from qt-creator/qt-creator
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:
@@ -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");
|
||||||
|
|
||||||
|
auto append = [this, timestamp, type, category, msg] {
|
||||||
if (rowCount() >= 1000000) // limit log to 1000000 items
|
if (rowCount() >= 1000000) // limit log to 1000000 items
|
||||||
destroyItem(itemForIndex(index(0, 0)));
|
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:
|
||||||
|
Reference in New Issue
Block a user