forked from qt-creator/qt-creator
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: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class ProjectExplorer::Internal::WinDebugInterface
|
\class ProjectExplorer::Internal::WinDebugInterface
|
||||||
@@ -135,13 +135,41 @@ bool WinDebugInterface::runLoop()
|
|||||||
|
|
||||||
SetEvent(m_bufferReadyEvent);
|
SetEvent(m_bufferReadyEvent);
|
||||||
|
|
||||||
|
QTime timer; // time since last signal sent
|
||||||
|
timer.start();
|
||||||
|
|
||||||
|
QMap<qint64, QString> delayedMessages;
|
||||||
|
|
||||||
while (true) {
|
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)
|
if (ret == WAIT_FAILED || ret - WAIT_OBJECT_0 == TerminateEventHandle)
|
||||||
break;
|
break;
|
||||||
if (ret - WAIT_OBJECT_0 == DataReadyEventHandle) {
|
if (ret == WAIT_TIMEOUT) {
|
||||||
if (*processId != m_creatorPid)
|
auto it = delayedMessages.constBegin();
|
||||||
emit debugOutput(*processId, QString::fromLocal8Bit(message));
|
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);
|
SetEvent(m_bufferReadyEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user