mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Use keysight implementation of the method removeObjserver:forKeyPath:context:
This commit is contained in:
parent
b8bc924cdb
commit
0f3bb3d2b8
2 changed files with 34 additions and 6 deletions
|
@ -138,10 +138,11 @@ GS_EXPORT NSString *const NSKeyValueChangeNotificationIsPriorKey;
|
|||
- (void) removeObserver: (NSObject*)anObserver
|
||||
forKeyPath: (NSString*)aPath;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7,GS_API_LATEST)
|
||||
- (void) removeObserver: (NSObject*)anObserver
|
||||
forKeyPath: (NSString*)aPath
|
||||
context: (void*)context;
|
||||
|
||||
forKeyPath: (NSString*)aPath
|
||||
context: (void *)context;
|
||||
#endif
|
||||
@end
|
||||
|
||||
@interface NSArray (NSKeyValueObserverRegistration)
|
||||
|
|
|
@ -1566,9 +1566,36 @@ cifframe_callback(ffi_cif *cif, void *retp, void **args, void *user)
|
|||
forKeyPath: (NSString*)aPath
|
||||
context: (void*)context
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"[%@-%@]: This class is not observable",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
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];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue