summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2011-06-20 09:52:18 (GMT)
committerKai Koehne <kai.koehne@nokia.com>2011-06-20 10:55:44 (GMT)
commitfab51c4220b84d15d517e698da59cfb05da02729 (patch)
tree5b9cd2790ea3012e52a658e6a97f14ed5bfea489 /src/plugins
parentf4cd86c5a147c91f8ab671627b96606b373bcc2d (diff)
downloadQt-fab51c4220b84d15d517e698da59cfb05da02729.zip
Qt-fab51c4220b84d15d517e698da59cfb05da02729.tar.gz
Qt-fab51c4220b84d15d517e698da59cfb05da02729.tar.bz2
QDeclarativeDebug: Fix cases where multiple packets arrive in one go
Make sure no packets get 'lost' when they're arriving in one go through the TCP/IP socket. Reviewed-by: Christiaan Janssen
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
index abc60e1..283f7d4 100644
--- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
@@ -125,7 +125,13 @@ void QTcpServerConnection::disconnect()
bool QTcpServerConnection::waitForMessage()
{
Q_D(QTcpServerConnection);
- return d->protocol->waitForReadyRead(-1);
+ if (d->protocol->packetsAvailable() > 0) {
+ QPacket packet = d->protocol->read();
+ d->debugServer->receiveMessage(packet.data());
+ return true;
+ } else {
+ return d->protocol->waitForReadyRead(-1);
+ }
}
void QTcpServerConnection::setPort(int port, bool block)
@@ -145,10 +151,11 @@ void QTcpServerConnection::listen()
d->tcpServer = new QTcpServer(this);
QObject::connect(d->tcpServer, SIGNAL(newConnection()), this, SLOT(newConnection()));
- if (d->tcpServer->listen(QHostAddress::Any, d->port))
+ if (d->tcpServer->listen(QHostAddress::Any, d->port)) {
qWarning("QDeclarativeDebugServer: Waiting for connection on port %d...", d->port);
- else
+ } else {
qWarning("QDeclarativeDebugServer: Unable to listen on port %d", d->port);
+ }
}
@@ -158,10 +165,10 @@ void QTcpServerConnection::readyRead()
if (!d->protocol)
return;
- QPacket packet = d->protocol->read();
-
- QByteArray content = packet.data();
- d->debugServer->receiveMessage(content);
+ while (d->protocol->packetsAvailable() > 0) {
+ QPacket packet = d->protocol->read();
+ d->debugServer->receiveMessage(packet.data());
+ }
}
void QTcpServerConnection::newConnection()