From: Jocelyn Turcotte Date: Wed, 1 Apr 2015 12:40:34 +0000 (+0200) Subject: Fix a crash on shutdown in ~SocketApi #3057 X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~1803^2~236 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4a893c5267ce625a44ed02b724832e6fa67dd899;p=nextcloud-desktop.git Fix a crash on shutdown in ~SocketApi #3057 Deleting the QLocalSocket while iterating the QList with qDeleteAll would trigger onLostConnection, which would modify the list mid-air and leave dangling pointers in it. --- diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp index 6bd86cc62..9688c81b6 100644 --- a/src/gui/socketapi.cpp +++ b/src/gui/socketapi.cpp @@ -136,7 +136,9 @@ SocketApi::~SocketApi() { DEBUG << "dtor"; _localServer.close(); - qDeleteAll(_listeners); + // All remaining sockets will be destroyed with _localServer, their parent + Q_ASSERT(_listeners.isEmpty() || _listeners.first()->parent() == &_localServer); + _listeners.clear(); slotClearExcludesList(); }