Commit a8b6f30c authored by Daniel Teske's avatar Daniel Teske

WinDebugInterface: Compress events

If there have been less than 60ms since the last event, the debug
listener thread doesn't immediately sent a signal, but postpone it.

Change-Id: I50c66173bc423f8d03c4f2bdde2273910972d58e
Task-number: QTCREATORBUG-14307
Reviewed-by: default avatarKai Koehne <kai.koehne@theqtcompany.com>
parent 6bb78124
......@@ -34,7 +34,7 @@
#include <windows.h>
#include <QApplication>
#include <QTime>
/*!
\class ProjectExplorer::Internal::WinDebugInterface
......@@ -135,13 +135,41 @@ bool WinDebugInterface::runLoop()
SetEvent(m_bufferReadyEvent);
QTime timer; // time since last signal sent
timer.start();
QMap<qint64, QString> delayedMessages;
while (true) {
const DWORD ret = WaitForMultipleObjects(HandleCount, m_waitHandles, FALSE, INFINITE);
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)
break;
if (ret - WAIT_OBJECT_0 == DataReadyEventHandle) {
if (*processId != m_creatorPid)
emit debugOutput(*processId, QString::fromLocal8Bit(message));
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();
SetEvent(m_bufferReadyEvent);
} else if (ret - WAIT_OBJECT_0 == DataReadyEventHandle) {
if (*processId != m_creatorPid) {
if (timer.elapsed() < 60) {
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();
}
}
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