Commit 283b2f1c authored by Daniel Teske's avatar Daniel Teske

WinDebugInterface: Flush messages on being stopped

I found this while investigating a bug report.

Change-Id: Ic756dfc4b1dfe1b1a647d5b10441391c97046176
Reviewed-by: default avatarKai Koehne <kai.koehne@theqtcompany.com>
parent ac4b3f33
......@@ -144,21 +144,27 @@ bool WinDebugInterface::runLoop()
QMap<qint64, QString> delayedMessages;
auto flushMessages = [&delayedMessages](){
auto it = delayedMessages.constBegin();
auto end = delayedMessages.constEnd();
for (; it != end; ++it)
emit debugOutput(it.key(), it.value());
delayedMessages.clear();
timer.start();
};
while (true) {
DWORD timeout = INFINITE;
if (!delayedMessages.isEmpty()) // if we have delayed message, don't wait forever
timeout = qMax(60 - timer.elapsed(), 1);
const DWORD ret = WaitForMultipleObjects(HandleCount, m_waitHandles, FALSE, timeout);
if (ret == WAIT_FAILED || ret - WAIT_OBJECT_0 == TerminateEventHandle)
if (ret == WAIT_FAILED || ret - WAIT_OBJECT_0 == TerminateEventHandle) {
flushMessages();
break;
}
if (ret == WAIT_TIMEOUT) {
auto it = delayedMessages.constBegin();
auto end = delayedMessages.constEnd();
for (; it != end; ++it)
emit debugOutput(it.key(), it.value());
delayedMessages.clear();
timer.start();
flushMessages();
SetEvent(m_bufferReadyEvent);
} else if (ret - WAIT_OBJECT_0 == DataReadyEventHandle) {
if (*processId != m_creatorPid) {
......@@ -166,12 +172,7 @@ bool WinDebugInterface::runLoop()
delayedMessages[*processId].append(QString::fromLocal8Bit(message));
} else {
delayedMessages[*processId] += QString::fromLocal8Bit(message);
auto it = delayedMessages.constBegin();
auto end = delayedMessages.constEnd();
for (; it != end; ++it)
emit debugOutput(it.key(), it.value());
delayedMessages.clear();
timer.start();
flushMessages();
}
}
SetEvent(m_bufferReadyEvent);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment