From 330382ce91b3ca59dfd3c3220a5c752858e3d102 Mon Sep 17 00:00:00 2001 From: Mike Odom <5105729+ThatOdieGuy@users.noreply.github.com> Date: Sun, 16 Dec 2018 15:52:51 -0800 Subject: [PATCH] Adding mutex lock to Logger ASSERT: "bytes <= bufferSize" in file tools\qringbuffer.cpp, line 74 This was happening when seeking multiple times very quickly in Player. QFile is not thread safe so I added a QMutexLocker to the Logger function. --- examples/common/common.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/common/common.cpp b/examples/common/common.cpp index cd031dced..12ff3b00c 100644 --- a/examples/common/common.cpp +++ b/examples/common/common.cpp @@ -35,6 +35,7 @@ #include #endif #include +#include #ifdef Q_OS_WINRT #include @@ -98,8 +99,13 @@ QtMsgHandler qInstallMessageHandler(QtMessageHandler h) { return qInstallMsgHandler(MsgHandlerWrapper::handler); } #endif + +QMutex loggerMutex; void Logger(QtMsgType type, const QMessageLogContext &, const QString& qmsg) { + // QFile is not thread-safe + QMutexLocker locker(&loggerMutex); + const QByteArray msgArray = qmsg.toUtf8(); const char* msg = msgArray.constData(); switch (type) {