From 6b8add7fd41a7aed23bc316d46049e45c684bb0d Mon Sep 17 00:00:00 2001 From: Nicolas Buquet Date: Tue, 10 Oct 2023 11:45:14 +0200 Subject: [PATCH 1/3] Release kMXKAccountAPNSActivityDidChangeNotification observer when deallocation controller Signed-off-by: Nicolas Buquet --- Riot/Modules/Settings/SettingsViewController.m | 9 +++++++++ changelog.d/Settings-controller-dealloc-observer.bugfix | 1 + 2 files changed, 10 insertions(+) create mode 100644 changelog.d/Settings-controller-dealloc-observer.bugfix diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 6f9c22465f..6bde0d3b51 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -340,6 +340,15 @@ - (void)finalizeInit self.screenTracker = [[AnalyticsScreenTracker alloc] initWithScreen:AnalyticsScreenSettings]; } +- (void)dealloc { + // Remove observers + if (pushInfoUpdateObserver) + { + [[NSNotificationCenter defaultCenter] removeObserver:pushInfoUpdateObserver name:kMXKAccountAPNSActivityDidChangeNotification object:nil]; + pushInfoUpdateObserver = nil; + } +} + - (void)updateSections { NSMutableArray *tmpSections = [NSMutableArray arrayWithCapacity:SECTION_TAG_DEACTIVATE_ACCOUNT + 1]; diff --git a/changelog.d/Settings-controller-dealloc-observer.bugfix b/changelog.d/Settings-controller-dealloc-observer.bugfix new file mode 100644 index 0000000000..836c27c268 --- /dev/null +++ b/changelog.d/Settings-controller-dealloc-observer.bugfix @@ -0,0 +1 @@ +Remove registered observer kMXKAccountAPNSActivityDidChangeNotification in dealloc of SettingsViewController \ No newline at end of file From af0ea7a6d1f4f53ff6b15e65fc873bcffbcb386f Mon Sep 17 00:00:00 2001 From: Nicolas Buquet Date: Tue, 24 Oct 2023 17:33:09 +0200 Subject: [PATCH 2/3] SettingsViewController : Call Destroy on dealloc to release all observers Signed-off-by: Nicolas Buquet --- Riot/Modules/Settings/SettingsViewController.m | 3 +++ changelog.d/Settings-controller-dealloc-observer.bugfix | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 6bde0d3b51..e0f4d28581 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -347,6 +347,9 @@ - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:pushInfoUpdateObserver name:kMXKAccountAPNSActivityDidChangeNotification object:nil]; pushInfoUpdateObserver = nil; } + + // Fix for destroy not being called + [self destroy]; } - (void)updateSections diff --git a/changelog.d/Settings-controller-dealloc-observer.bugfix b/changelog.d/Settings-controller-dealloc-observer.bugfix index 836c27c268..b52c547ad6 100644 --- a/changelog.d/Settings-controller-dealloc-observer.bugfix +++ b/changelog.d/Settings-controller-dealloc-observer.bugfix @@ -1 +1 @@ -Remove registered observer kMXKAccountAPNSActivityDidChangeNotification in dealloc of SettingsViewController \ No newline at end of file +Call destroy in dealloc to remove all observers of SettingsViewController \ No newline at end of file From d50b82adeb247cfef72f6f5a6682699487ce06b2 Mon Sep 17 00:00:00 2001 From: Nicolas Buquet Date: Wed, 25 Oct 2023 10:38:31 +0200 Subject: [PATCH 3/3] Don't remove `pushInfoUpdateObserver` in dealloc because it is removed in `destroy`. Signed-off-by: Nicolas Buquet --- Riot/Modules/Settings/SettingsViewController.m | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index e0f4d28581..39698f765f 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -341,13 +341,6 @@ - (void)finalizeInit } - (void)dealloc { - // Remove observers - if (pushInfoUpdateObserver) - { - [[NSNotificationCenter defaultCenter] removeObserver:pushInfoUpdateObserver name:kMXKAccountAPNSActivityDidChangeNotification object:nil]; - pushInfoUpdateObserver = nil; - } - // Fix for destroy not being called [self destroy]; }