qtmain_winrt: Synchronize debug message calls
When winrtrunner is used to debug winrt applications, debug messages should be acknowledged by winrtrunner. Otherwise it is possible, that 2 messages are sent (and their event set) before winrtrunner reacted. In this case the first message was lost and the second message shown twice. Change-Id: Ib1c6f87aad0c0da1761be5bf467edf8d4476c5e3 Reviewed-by: Miguel Costa <miguel.costa@qt.io> Reviewed-by: Andre de la Rocha <andre.rocha@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
This commit is contained in:
parent
4e74494c7e
commit
8342382e23
@ -93,6 +93,7 @@ static void devMessageHandler(QtMsgType type, const QMessageLogContext &context,
|
||||
{
|
||||
static HANDLE shmem = 0;
|
||||
static HANDLE event = 0;
|
||||
static HANDLE ackEvent = 0;
|
||||
|
||||
static QMutex messageMutex;
|
||||
QMutexLocker locker(&messageMutex);
|
||||
@ -101,6 +102,8 @@ static void devMessageHandler(QtMsgType type, const QMessageLogContext &context,
|
||||
shmem = CreateFileMappingFromApp(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 4096, L"qdebug-shmem");
|
||||
if (!event)
|
||||
event = CreateEventEx(NULL, L"qdebug-event", 0, EVENT_ALL_ACCESS);
|
||||
if (!ackEvent)
|
||||
ackEvent = CreateEventEx(NULL, L"qdebug-event-ack", 0, EVENT_ALL_ACCESS);
|
||||
|
||||
Q_ASSERT_X(shmem, Q_FUNC_INFO, "Could not create file mapping");
|
||||
Q_ASSERT_X(event, Q_FUNC_INFO, "Could not create debug event");
|
||||
@ -113,6 +116,7 @@ static void devMessageHandler(QtMsgType type, const QMessageLogContext &context,
|
||||
message.data(), (message.length() + 1) * sizeof(wchar_t));
|
||||
UnmapViewOfFile(data);
|
||||
SetEvent(event);
|
||||
WaitForSingleObjectEx(ackEvent, INFINITE, false);
|
||||
locker.unlock();
|
||||
defaultMessageHandler(type, context, message);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user