From 0cdce37af491c418e2d9f323ddb55ef7662282c5 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 31 Jan 2020 22:37:21 +0100 Subject: [PATCH] added proper unregister calls in destructors of classes that register a event handler --- retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp | 2 ++ retroshare-gui/src/gui/Identity/IdDialog.cpp | 3 +++ retroshare-gui/src/gui/Posted/PostedDialog.cpp | 1 + retroshare-gui/src/gui/common/NewFriendList.cpp | 1 + retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp | 1 + retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp | 1 + retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp | 1 + retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp | 1 + retroshare-gui/src/gui/statusbar/hashingstatus.cpp | 1 + retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp | 5 +++++ retroshare-gui/src/util/RsGxsUpdateBroadcast.h | 3 +++ 11 files changed, 20 insertions(+) diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index d2ec0ee54..22486fd2c 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -1117,6 +1117,8 @@ void TransfersDialog::handleEvent(std::shared_ptr event) TransfersDialog::~TransfersDialog() { + rsEvents->unregisterEventsHandler(mEventHandlerId); + // save settings processSettings(false); } diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index ffb29664a..30e53c993 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -1377,6 +1377,9 @@ void IdDialog::circle_selected() IdDialog::~IdDialog() { + rsEvents->unregisterEventsHandler(mEventHandlerId_identity); + rsEvents->unregisterEventsHandler(mEventHandlerId_circles); + // save settings processSettings(false); diff --git a/retroshare-gui/src/gui/Posted/PostedDialog.cpp b/retroshare-gui/src/gui/Posted/PostedDialog.cpp index 5e743b957..e696db36c 100644 --- a/retroshare-gui/src/gui/Posted/PostedDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedDialog.cpp @@ -83,6 +83,7 @@ void PostedDialog::handleEvent_main_thread(std::shared_ptr event) PostedDialog::~PostedDialog() { + rsEvents->unregisterEventsHandler(mEventHandlerId); } UserNotify *PostedDialog::createUserNotify(QObject *parent) diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index cb4c68030..302ce9310 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -266,6 +266,7 @@ void NewFriendList::handleEvent(std::shared_ptr e) NewFriendList::~NewFriendList() { + rsEvents->unregisterEventsHandler(mEventHandlerId); delete ui; } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp index f031772b3..64ed0f8e6 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp @@ -88,6 +88,7 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr ev GxsChannelDialog::~GxsChannelDialog() { + rsEvents->unregisterEventsHandler(mEventHandlerId); } QString GxsChannelDialog::getHelpString() const diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index 7985d6489..3286c5f8b 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -158,6 +158,7 @@ void GxsChannelPostsWidget::handleEvent_main_thread(std::shared_ptrunregisterEventsHandler(mEventHandlerId); // save settings processSettings(false); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index f57d29119..85343fdb8 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -490,6 +490,7 @@ void GxsForumThreadWidget::blank() GxsForumThreadWidget::~GxsForumThreadWidget() { + rsEvents->unregisterEventsHandler(mEventHandlerId); // save settings processSettings(false); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp index 7d5889e4d..71766ca63 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp @@ -83,6 +83,7 @@ void GxsForumsDialog::handleEvent_main_thread(std::shared_ptr eve GxsForumsDialog::~GxsForumsDialog() { + rsEvents->unregisterEventsHandler(mEventHandlerId); } QString GxsForumsDialog::getHelpString() const diff --git a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp index 0afcec9cc..997ca5f8f 100644 --- a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp @@ -87,6 +87,7 @@ void HashingStatus::handleEvent(std::shared_ptr event) HashingStatus::~HashingStatus() { + rsEvents->unregisterEventsHandler(mEventHandlerId); delete(movie); } diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp index 934226da4..efd54a8e7 100644 --- a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp @@ -45,6 +45,11 @@ RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) : }, mEventHandlerId ); } +RsGxsUpdateBroadcast::~RsGxsUpdateBroadcast() +{ + rsEvents->unregisterEventsHandler(mEventHandlerId); +} + void RsGxsUpdateBroadcast::cleanup() { QMap::iterator it; diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.h b/retroshare-gui/src/util/RsGxsUpdateBroadcast.h index 1383c18dd..1ec733bfa 100644 --- a/retroshare-gui/src/util/RsGxsUpdateBroadcast.h +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.h @@ -40,6 +40,9 @@ public: static RsGxsUpdateBroadcast *get(RsGxsIfaceHelper* ifaceImpl); +protected: + virtual ~RsGxsUpdateBroadcast(); + signals: void changed(); void msgsChanged(const std::map >& msgIds, const std::map >& msgIdsMeta);