From: Mikko Rasa Date: Sat, 17 Oct 2015 10:54:09 +0000 (+0300) Subject: Fix a bug in receiving data from the server X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5bb8258cd0c2a5600bc90ac9f7dc06b4746a16f9;p=xinema.git Fix a bug in receiving data from the server QIODevice::readyRead is edge-triggered, not level-triggered. Thus it can't be relied on to be triggered again if only part of the available data is read. --- diff --git a/remote/source/xinemacontrol.cpp b/remote/source/xinemacontrol.cpp index db349e7..f793e3b 100644 --- a/remote/source/xinemacontrol.cpp +++ b/remote/source/xinemacontrol.cpp @@ -64,12 +64,16 @@ void XinemaControl::send_request(const QString &req) void XinemaControl::data_available() { - char rbuf[1024]; - int len = socket.read(rbuf, sizeof(rbuf)); - if(len<0) - return; + while(socket.bytesAvailable()) + { + char rbuf[1024]; + int len = socket.read(rbuf, sizeof(rbuf)); + if(len<0) + break; + + buffer.append(rbuf, len); + } - buffer.append(rbuf, len); unsigned start = 0; while(1) {