summaryrefslogtreecommitdiffstats
path: root/src/winmain/qtmain_winrt.cpp
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2018-03-27 14:05:35 +0200
committerOliver Wolff <oliver.wolff@qt.io>2018-04-09 06:48:48 +0000
commit4e74494c7e3e80206221c3a70fc2338107b68c7c (patch)
tree14d72ffff2fd3c0aa35af15d90ba1733f5958d41 /src/winmain/qtmain_winrt.cpp
parente759d38d491d9044a0558b1d45911e3b4115e772 (diff)
qtmain_winrt: Protect debug message handler with mutex
The code can be accessed from several threads and thus should be protected. Change-Id: I38c67c5d0f9b1658da1d0ae45d3ea79bbe4e8dff Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Miguel Costa <miguel.costa@qt.io> Reviewed-by: Andre de la Rocha <andre.rocha@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'src/winmain/qtmain_winrt.cpp')
-rw-r--r--src/winmain/qtmain_winrt.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/winmain/qtmain_winrt.cpp b/src/winmain/qtmain_winrt.cpp
index b072248603..57724b0d36 100644
--- a/src/winmain/qtmain_winrt.cpp
+++ b/src/winmain/qtmain_winrt.cpp
@@ -69,6 +69,7 @@ extern "C" {
#include <qstandardpaths.h>
#include <qfunctions_winrt.h>
#include <qcoreapplication.h>
+#include <qmutex.h>
#include <wrl.h>
#include <Windows.ApplicationModel.core.h>
@@ -92,6 +93,10 @@ static void devMessageHandler(QtMsgType type, const QMessageLogContext &context,
{
static HANDLE shmem = 0;
static HANDLE event = 0;
+
+ static QMutex messageMutex;
+ QMutexLocker locker(&messageMutex);
+
if (!shmem)
shmem = CreateFileMappingFromApp(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 4096, L"qdebug-shmem");
if (!event)
@@ -108,6 +113,7 @@ static void devMessageHandler(QtMsgType type, const QMessageLogContext &context,
message.data(), (message.length() + 1) * sizeof(wchar_t));
UnmapViewOfFile(data);
SetEvent(event);
+ locker.unlock();
defaultMessageHandler(type, context, message);
}