core/log: add a mutex to protect stdoutStream

QTextStream is not thread safe.
This commit is contained in:
Dan Aloni 2025-10-03 17:11:03 +03:00 committed by outfoxxed
parent 7511545ee2
commit eb6eaf59c7
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
2 changed files with 4 additions and 0 deletions

View file

@ -14,6 +14,7 @@
#include <qlist.h>
#include <qlogging.h>
#include <qloggingcategory.h>
#include <qmutex.h>
#include <qnamespace.h>
#include <qobject.h>
#include <qobjectdefs.h>
@ -220,6 +221,7 @@ void LogManager::messageHandler(
}
if (display) {
auto locker = QMutexLocker(&self->stdoutMutex);
LogMessage::formatMessage(
self->stdoutStream,
message,

View file

@ -10,6 +10,7 @@
#include <qlatin1stringview.h>
#include <qlogging.h>
#include <qloggingcategory.h>
#include <qmutex.h>
#include <qobject.h>
#include <qtmetamacros.h>
@ -135,6 +136,7 @@ private:
QHash<QLatin1StringView, CategoryFilter> allFilters;
QTextStream stdoutStream;
QMutex stdoutMutex;
LoggingThreadProxy threadProxy;
friend void initLogCategoryLevel(const char* name, QtMsgType defaultLevel);