Skip to content

Commit defde89

Browse files
Fixing crash in darwin framework (project-chip#33698)
* Fixing crash * Restyled by clang-format * Reminder for future me * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent c1e1e6e commit defde89

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/darwin/Framework/CHIP/MTRDevice.mm

+7-5
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,7 @@ - (void)_changeInternalState:(MTRInternalDeviceState)state
963963
MTR_LOG("%@ internal state change %lu => %lu", self, static_cast<unsigned long>(lastState), static_cast<unsigned long>(state));
964964

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

3654+
// TODO: This should always return YES for thread devices
36533655
return HaveSubscriptionEstablishedRightNow(_internalDeviceState);
36543656
}
36553657

36563658
- (void)_deviceMayBeReachable
36573659
{
3658-
assertChipStackLockedByCurrentThread();
3659-
36603660
MTR_LOG("%@ _deviceMayBeReachable called", self);
3661-
3662-
[self _triggerResubscribeWithReason:@"SPI client indicated the device may now be reachable"
3663-
nodeLikelyReachable:YES];
3661+
// TODO: This should only be allowed for thread devices
3662+
[_deviceController asyncDispatchToMatterQueue:^{
3663+
[self _triggerResubscribeWithReason:@"SPI client indicated the device may now be reachable"
3664+
nodeLikelyReachable:YES];
3665+
} errorHandler:nil];
36643666
}
36653667

36663668
/* END DRAGONS */

0 commit comments

Comments
 (0)