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) {