Skip to content

Commit

Permalink
Fix retain cycles in MXEventListener & MXRoomSummary
Browse files Browse the repository at this point in the history
Relates to: element-hq/element-ios#5058
Signed-off-by: Johannes Marbach <[email protected]>
  • Loading branch information
Johennes committed Mar 27, 2022
1 parent 358e2f0 commit a744830
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion MatrixSDK/Data/MXEventListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typedef void (^MXOnEvent)(MXEvent *event, MXTimelineDirection direction, id _Nul
*/
- (void)notify:(MXEvent*)event direction:(MXTimelineDirection)direction andCustomObject:(nullable id)customObject;

@property (nonatomic, readonly) id sender;
@property (nonatomic, weak, readonly) id sender;
@property (nonatomic, nullable, readonly) NSArray<MXEventTypeString>* eventTypes;
@property (nonatomic, readonly) MXOnEvent listenerBlock;

Expand Down
2 changes: 2 additions & 0 deletions MatrixSDK/Data/MXRoomSummary.m
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ - (MXHTTPOperation *)fetchLastMessageWithMaxServerPaginationCount:(NSUInteger)ma

// Process every message received by back pagination
__block BOOL lastMessageUpdated = NO;
MXWeakify(timeline);
[timeline listenToEvents:^(MXEvent *event, MXTimelineDirection direction, MXRoomState *eventState) {
MXStrongifyAndReturnIfNil(timeline);
if (direction == MXTimelineDirectionBackwards
&& !lastMessageUpdated)
{
Expand Down
1 change: 1 addition & 0 deletions changelog.d/5058.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MXEventListener/MXRoomSummary: Fix retain cycles

0 comments on commit a744830

Please sign in to comment.