From 99cd51d5a23b70a4dce2ddd7270320376c07fa56 Mon Sep 17 00:00:00 2001 From: dail8859 Date: Tue, 22 Dec 2020 20:49:50 -0500 Subject: Remove ConnectionInfo after socket is destroyed This leaves the ConnectionInfo in a valid state, even after the socket is disconnected, which could still have a readyRead() signal emitted. Closes #123 --- singleapplication_p.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/singleapplication_p.cpp b/singleapplication_p.cpp index 1ab58c2..70edaae 100644 --- a/singleapplication_p.cpp +++ b/singleapplication_p.cpp @@ -328,10 +328,12 @@ void SingleApplicationPrivate::slotConnectionEstablished() } ); - QObject::connect(nextConnSocket, &QLocalSocket::disconnected, - [nextConnSocket, this](){ + QObject::connect(nextConnSocket, &QLocalSocket::disconnected, nextConnSocket, &QLocalSocket::deleteLater); + + QObject::connect(nextConnSocket, &QLocalSocket::destroyed, + [nextConnSocket, this](QObject *obj){ + Q_UNUSED(obj) connectionMap.remove(nextConnSocket); - nextConnSocket->deleteLater(); } ); -- cgit v1.2.1 From 5e7b302776cfe476047d0bb29c5f64fe1ed47bbe Mon Sep 17 00:00:00 2001 From: dail8859 Date: Wed, 23 Dec 2020 15:42:56 -0500 Subject: Update singleapplication_p.cpp Co-authored-by: Hennadii Chernyshchyk --- singleapplication_p.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/singleapplication_p.cpp b/singleapplication_p.cpp index 70edaae..e65bd95 100644 --- a/singleapplication_p.cpp +++ b/singleapplication_p.cpp @@ -331,8 +331,7 @@ void SingleApplicationPrivate::slotConnectionEstablished() QObject::connect(nextConnSocket, &QLocalSocket::disconnected, nextConnSocket, &QLocalSocket::deleteLater); QObject::connect(nextConnSocket, &QLocalSocket::destroyed, - [nextConnSocket, this](QObject *obj){ - Q_UNUSED(obj) + [nextConnSocket, this](){ connectionMap.remove(nextConnSocket); } ); -- cgit v1.2.1