Skip to content

Commit

Permalink
Fixing crash in darwin framework (project-chip#33698)
Browse files Browse the repository at this point in the history
* Fixing crash

* Restyled by clang-format

* Reminder for future me

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
woody-apple and restyled-commits authored Jun 1, 2024
1 parent c1e1e6e commit defde89
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ - (void)_changeInternalState:(MTRInternalDeviceState)state
MTR_LOG("%@ internal state change %lu => %lu", self, static_cast<unsigned long>(lastState), static_cast<unsigned long>(state));

/* BEGIN DRAGONS: This is a huge hack for a specific use case, do not rename, remove or modify behavior here */
// TODO: This should only be called for thread devices
id<MTRDeviceDelegate> delegate = _weakDelegate.strongObject;
if ([delegate respondsToSelector:@selector(_deviceInternalStateChanged:)]) {
dispatch_async(_delegateQueue, ^{
Expand Down Expand Up @@ -3650,17 +3651,18 @@ - (BOOL)_deviceHasActiveSubscription
{
std::lock_guard lock(_lock);

// TODO: This should always return YES for thread devices
return HaveSubscriptionEstablishedRightNow(_internalDeviceState);
}

- (void)_deviceMayBeReachable
{
assertChipStackLockedByCurrentThread();

MTR_LOG("%@ _deviceMayBeReachable called", self);

[self _triggerResubscribeWithReason:@"SPI client indicated the device may now be reachable"
nodeLikelyReachable:YES];
// TODO: This should only be allowed for thread devices
[_deviceController asyncDispatchToMatterQueue:^{
[self _triggerResubscribeWithReason:@"SPI client indicated the device may now be reachable"
nodeLikelyReachable:YES];
} errorHandler:nil];
}

/* END DRAGONS */
Expand Down

0 comments on commit defde89

Please sign in to comment.