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>
This commit is contained in:
parent
e759d38d49
commit
4e74494c7e
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user