From 823897a5042dc79d548865adf405be947da8f14b Mon Sep 17 00:00:00 2001 From: Nicolas Buquet Date: Wed, 11 Oct 2023 13:58:51 +0200 Subject: [PATCH] Correct cleaning (dealloc) of controller and observers --- .../Modules/Settings/SettingsViewController.m | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 1e56e4325..f09037aa9 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -378,19 +378,9 @@ - (void)finalizeInit self.screenTracker = [[AnalyticsScreenTracker alloc] initWithScreen:AnalyticsScreenSettings]; } +// Tchap: fix for destroy not being called (https://github.com/vector-im/element-ios/pull/7697) - (void)dealloc { - // Remove observers - if (pushInfoUpdateObserver) - { - [[NSNotificationCenter defaultCenter] removeObserver:pushInfoUpdateObserver name:kMXKAccountAPNSActivityDidChangeNotification object:nil]; - pushInfoUpdateObserver = nil; - } - - if (emailInfoUpdateObserver) - { - [[NSNotificationCenter defaultCenter] removeObserver:emailInfoUpdateObserver name:kMXKAccountEmailActivityDidChangeNotification object:nil]; - emailInfoUpdateObserver = nil; - } + [self destroy]; } - (void)updateSections @@ -1033,6 +1023,13 @@ - (void)reset pushInfoUpdateObserver = nil; } + // Tchap: remove Email notification update observer + if (emailInfoUpdateObserver) + { + [[NSNotificationCenter defaultCenter] removeObserver:emailInfoUpdateObserver name:kMXKAccountEmailActivityDidChangeNotification object:nil]; + emailInfoUpdateObserver = nil; + } + [[NSNotificationCenter defaultCenter] removeObserver:self]; onReadyToDestroyHandler = nil;