Skip to content

Commit

Permalink
[Matter.framework] Clear all device controller delegates on controlle…
Browse files Browse the repository at this point in the history
…r shutdown (#35935)
  • Loading branch information
vivien-apple authored and pull[bot] committed Oct 24, 2024
1 parent 0839f7b commit 3243451
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/darwin/Framework/CHIP/MTRDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ - (void)_controllerResumed

- (void)shutdown
{
// Subclass hook; nothing to do.
[self _clearDeviceControllerDelegates];
}

- (nullable NSNumber *)controllerNodeID
Expand Down Expand Up @@ -671,6 +671,14 @@ - (void)removeDeviceControllerDelegate:(id<MTRDeviceControllerDelegate>)delegate
}
}

- (void)_clearDeviceControllerDelegates
{
@synchronized(self) {
_strongDelegateForSetDelegateAPI = nil;
[_delegates removeAllObjects];
}
}

// Iterates the delegates, and remove delegate info objects if the delegate object has dealloc'ed
// Returns number of delegates called
- (NSUInteger)_iterateDelegateInfoWithBlock:(void (^_Nullable)(MTRDeviceControllerDelegateInfo * delegateInfo))block
Expand Down
1 change: 1 addition & 0 deletions src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ - (void)shutdown
return;
}
[self finalShutdown];
[super shutdown];
}

- (void)finalShutdown
Expand Down

0 comments on commit 3243451

Please sign in to comment.