Skip to content

Commit

Permalink
Correct cleaning (dealloc) of controller and observers
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Buquet committed Oct 11, 2023
1 parent b2b2be5 commit 823897a
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions Riot/Modules/Settings/SettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 823897a

Please sign in to comment.