Skip to content

Commit

Permalink
Remove retain cycles preventing MXCrypto to be released
Browse files Browse the repository at this point in the history
  • Loading branch information
nimau committed Feb 10, 2023
1 parent 769c96a commit abce798
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions MatrixSDK/Crypto/KeyBackup/Engine/MXNativeKeyBackupEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ - (BOOL)enableBackupWithKeyBackupVersion:(MXKeyBackupVersion *)keyBackupVersion
self.crypto.store.backupVersion = keyBackupVersion.version;
Class algorithmClass = AlgorithmClassesByName[keyBackupVersion.algorithm];
// store the desired backup algorithm
MXWeakify(self);
self.keyBackupAlgorithm = [[algorithmClass alloc] initWithCrypto:self.crypto authData:authData keyGetterBlock:^NSData * _Nullable{
MXStrongifyAndReturnValueIfNil(self, nil);
return self.privateKey;
}];
MXLogDebug(@"[MXNativeKeyBackupEngine] enableBackupWithVersion: Algorithm set to: %@", self.keyBackupAlgorithm);
Expand Down
3 changes: 3 additions & 0 deletions MatrixSDK/Crypto/MXCrypto.m
Original file line number Diff line number Diff line change
Expand Up @@ -2665,8 +2665,11 @@ - (void)registerEventHandlers
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onToDeviceEvent:) name:kMXSessionOnToDeviceEventNotification object:self.mxSession];

// Observe membership changes
MXWeakify(self);
self->roomMembershipEventsListener = [self.mxSession listenToEventsOfTypes:@[kMXEventTypeStringRoomEncryption, kMXEventTypeStringRoomMember] onEvent:^(MXEvent *event, MXTimelineDirection direction, id customObject) {

MXStrongifyAndReturnIfNil(self);

if (direction == MXTimelineDirectionForwards)
{
if (event.eventType == MXEventTypeRoomEncryption)
Expand Down

0 comments on commit abce798

Please sign in to comment.