summaryrefslogtreecommitdiffstats
path: root/qtsingleapplication/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-05-08 16:23:08 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-05-10 07:36:24 +0000
commit1fca9c330d8548d84fccb66407fbaf3aae122d17 (patch)
treeea5bfec470df65545f0c3c932d42bb744d7e2955 /qtsingleapplication/src
parent5eac28ccd8bfdcad0000d053519547c8ad8991fe (diff)
QtSingleApplication: Bail out of read loop when peer disconnects
When messages are received while the event loop is inactive (for example, when locked by a native dialog), it can happen that a new connection is triggered which then goes into unconnected state when the peer terminates. Add a check to the loop and discard the connection in that case. Task-number: QTSOLBUG-193 Change-Id: I7d5502cb411d2b967bd06fe8734b97fee54b7d18 Reviewed-by: Joni Poikelin <joni.poikelin@qt.io> Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'qtsingleapplication/src')
-rw-r--r--qtsingleapplication/src/qtlocalpeer.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/qtsingleapplication/src/qtlocalpeer.cpp b/qtsingleapplication/src/qtlocalpeer.cpp
index c7ce527..f69463a 100644
--- a/qtsingleapplication/src/qtlocalpeer.cpp
+++ b/qtsingleapplication/src/qtlocalpeer.cpp
@@ -176,8 +176,17 @@ void QtLocalPeer::receiveConnection()
if (!socket)
return;
- while (socket->bytesAvailable() < (int)sizeof(quint32))
+ while (true) {
+ if (socket->state() == QAbstractSocket::UnconnectedState) {
+ qWarning("QtLocalPeer: Peer disconnected");
+ delete socket;
+ return;
+ }
+ if (socket->bytesAvailable() >= qint64(sizeof(quint32)))
+ break;
socket->waitForReadyRead();
+ }
+
QDataStream ds(socket);
QByteArray uMsg;
quint32 remaining;