From 4a893c5267ce625a44ed02b724832e6fa67dd899 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Wed, 1 Apr 2015 14:40:34 +0200 Subject: [PATCH] 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. --- src/gui/socketapi.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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(); } -- 2.30.2