@@ -708,8 +708,8 @@ - (void)_scheduleNextUpdate:(UInt64)nextUpdateInSeconds
708
708
{
709
709
mtr_weakify(self);
710
710
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (nextUpdateInSeconds * NSEC_PER_SEC)), self.queue, ^{
711
- MTR_LOG_DEBUG("%@ Timer expired, start Device Time Update", self);
712
711
mtr_strongify(self);
712
+ MTR_LOG_DEBUG("%@ Timer expired, start Device Time Update", self);
713
713
if (self) {
714
714
[self _performScheduledTimeUpdate];
715
715
} else {
@@ -3659,8 +3659,12 @@ - (void)invokeCommands:(NSArray<NSArray<MTRCommandWithRequiredResponse *> *> *)c
3659
3659
for (NSArray<MTRCommandWithRequiredResponse *> * commandGroup in [commands reverseObjectEnumerator]) {
3660
3660
// We want to invoke all the commands in the group in order, propagating along the list of
3661
3661
// current responses. Build up that linked list of command invokes via chaining the completions.
3662
+ mtr_weakify(self);
3662
3663
for (MTRCommandWithRequiredResponse * command in [commandGroup reverseObjectEnumerator]) {
3663
3664
auto commandInvokeBlock = ^(BOOL allSucceededSoFar, NSArray<MTRDeviceResponseValueDictionary> * previousResponses) {
3665
+ mtr_strongify(self);
3666
+ VerifyOrReturn(self, MTR_LOG_DEBUG("invokeCommands commandInvokeBlock called back with nil MTRDevice"));
3667
+
3664
3668
[self invokeCommandWithEndpointID:command.path.endpoint
3665
3669
clusterID:command.path.cluster
3666
3670
commandID:command.path.command
@@ -3669,6 +3673,8 @@ - (void)invokeCommands:(NSArray<NSArray<MTRCommandWithRequiredResponse *> *> *)c
3669
3673
expectedValueInterval:nil
3670
3674
queue:self.queue
3671
3675
completion:^(NSArray<NSDictionary<NSString *, id> *> * responses, NSError * error) {
3676
+ mtr_strongify(self);
3677
+ VerifyOrReturn(self, MTR_LOG_DEBUG("invokeCommands invokeCommandWithEndpointID completion called back with nil MTRDevice"));
3672
3678
if (error != nil) {
3673
3679
nextCompletion(NO, [previousResponses arrayByAddingObject:@ {
3674
3680
MTRCommandPathKey : command.path,
@@ -3701,6 +3707,9 @@ - (void)invokeCommands:(NSArray<NSArray<MTRCommandWithRequiredResponse *> *> *)c
3701
3707
}
3702
3708
3703
3709
auto commandGroupInvokeBlock = ^(BOOL allSucceededSoFar, NSArray<MTRDeviceResponseValueDictionary> * previousResponses) {
3710
+ mtr_strongify(self);
3711
+ VerifyOrReturn(self, MTR_LOG_DEBUG("invokeCommands commandGroupInvokeBlock called back with nil MTRDevice"));
3712
+
3704
3713
if (allSucceededSoFar == NO) {
3705
3714
// Don't start a new command group if something failed in the
3706
3715
// previous one. Note that we might be running on self.queue here, so make sure we
0 commit comments