From 4b54990846ed32b5d4bcb7c9f2cc8b27e74f4d59 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Fri, 15 Sep 2023 14:57:29 -0400 Subject: [PATCH] Move info method to the right place --- Source/NSKeyValueObserving.m | 87 ++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/Source/NSKeyValueObserving.m b/Source/NSKeyValueObserving.m index f3614abf7..5055daa39 100644 --- a/Source/NSKeyValueObserving.m +++ b/Source/NSKeyValueObserving.m @@ -1288,6 +1288,50 @@ - (void*) contextForObserver: (NSObject*)anObserver ofKeyPath: (NSString*)aPath [iLock unlock]; return context; } + +- (void) removeObserver: (NSObject*)anObserver + forKeyPath: (NSString*)aPath + context: (void*)context +{ + GSKVOPathInfo *pathInfo; + + [iLock lock]; + pathInfo = (GSKVOPathInfo*)NSMapGet(paths, (void*)aPath); + if (pathInfo != nil) + { + unsigned count = [pathInfo->observations count]; + + pathInfo->allOptions = 0; + while (count-- > 0) + { + GSKVOObservation *o; + + o = [pathInfo->observations objectAtIndex: count]; + if ((o->observer == anObserver || o->observer == nil) && + (o->context == context)) + { + [pathInfo->observations removeObjectAtIndex: count]; + if ([pathInfo->observations count] == 0) + { + NSMapRemove(paths, (void*)aPath); + } + } + else + { + pathInfo->allOptions |= o->options; + } + } + } + [iLock unlock]; +} + +- (void)removeObserver:(NSObject *)observer + fromObjectsAtIndexes:(NSIndexSet *)indexes + forKeyPath:(NSString *)keyPath + context:(void *)context +{ +} + @end @implementation NSKeyValueObservationForwarder @@ -1562,49 +1606,6 @@ - (void) removeObserver: (NSObject*)anObserver forKeyPath: (NSString*)aPath } -- (void) removeObserver: (NSObject*)anObserver - forKeyPath: (NSString*)aPath - context: (void*)context -{ - GSKVOPathInfo *pathInfo; - - [kvoLock lock]; - pathInfo = (GSKVOPathInfo*)NSMapGet(paths, (void*)aPath); - if (pathInfo != nil) - { - unsigned count = [pathInfo->observations count]; - - pathInfo->allOptions = 0; - while (count-- > 0) - { - GSKVOObservation *o; - - o = [pathInfo->observations objectAtIndex: count]; - if ((o->observer == anObserver || o->observer == nil) && - (o->context == context)) - { - [pathInfo->observations removeObjectAtIndex: count]; - if ([pathInfo->observations count] == 0) - { - NSMapRemove(paths, (void*)aPath); - } - } - else - { - pathInfo->allOptions |= o->options; - } - } - } - [kvoLock unlock]; -} - -- (void)removeObserver:(NSObject *)observer - fromObjectsAtIndexes:(NSIndexSet *)indexes - forKeyPath:(NSString *)keyPath - context:(void *)context -{ -} - @end /**