Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Frameworks/Foundation/NSKVOSupport.mm
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ static void _addNestedObserversAndOptionallyDependents(_NSKVOKeyObserver* keyObs
}

// If restOfKeypath is non-nil, we have to chain on further observers.
if (keyObserver.restOfKeypath) {
if (keyObserver.restOfKeypath && !keyObserver.restOfKeypathObserver) {
keyObserver.restOfKeypathObserver =
_addKeypathObserver([object valueForKey:key], keyObserver.restOfKeypath, keypathObserver, keyObserver.affectedObservers);
}
Expand Down Expand Up @@ -552,9 +552,8 @@ static inline id _valueForPendingChangeAtIndexes(
inline static void _dispatchWillChange(id notifyingObject, NSString* key, TFunc&& func) {
_NSKVOObservationInfo* observationInfo = (__bridge _NSKVOObservationInfo*)[notifyingObject observationInfo];
for (_NSKVOKeyObserver* keyObserver in [observationInfo observersForKey:key]) {
_NSKVOKeypathObserver* keypathObserver = keyObserver.keypathObserver;

// Skip any keypaths that are in the process of changing.
_NSKVOKeypathObserver* keypathObserver = keyObserver.keypathObserver;
if ([keypathObserver pushWillChange]) {
// Call into the lambda function, which will do the actual set-up for pendingChanges
func(keyObserver);
Expand All @@ -569,10 +568,10 @@ inline static void _dispatchWillChange(id notifyingObject, NSString* key, TFunc&
context:keypathObserver.context];
[change removeObjectForKey:NSKeyValueChangeNotificationIsPriorKey];
}

// This must happen regardless of whether we are currently notifying.
_removeNestedObserversAndOptionallyDependents(keyObserver, false);
}

// This must happen regardless of whether we are currently notifying.
_removeNestedObserversAndOptionallyDependents(keyObserver, false);
}
}

Expand Down