]> git.tdb.fi Git - xinema.git/commitdiff
Fix a bug in receiving data from the server
authorMikko Rasa <tdb@tdb.fi>
Sat, 17 Oct 2015 10:54:09 +0000 (13:54 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 17 Oct 2015 10:54:09 +0000 (13:54 +0300)
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.

remote/source/xinemacontrol.cpp

index db349e73685a7d0472a9a9b7dd9cd0dba860389b..f793e3bb0f1a271fcb69e119fc4692d29ae75b1c 100644 (file)
@@ -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)
        {