Skip to content

Commit

Permalink
qtmain_winrt: Protect debug message handler with mutex
Browse files Browse the repository at this point in the history
The code can be accessed from several threads and thus should be
protected.

Change-Id: I38c67c5d0f9b1658da1d0ae45d3ea79bbe4e8dff
Reviewed-by: Mårten Nordheim <[email protected]>
Reviewed-by: Miguel Costa <[email protected]>
Reviewed-by: Andre de la Rocha <[email protected]>
Reviewed-by: Maurice Kalinowski <[email protected]>
  • Loading branch information
owolff committed Apr 9, 2018
1 parent e759d38 commit 4e74494
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/winmain/qtmain_winrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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)
Expand All @@ -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);
}

Expand Down

0 comments on commit 4e74494

Please sign in to comment.