mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
fix weak pointer error
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28061 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fefde8fb99
commit
a9c800575e
2 changed files with 15 additions and 12 deletions
|
@ -1029,8 +1029,8 @@ static NSNotificationCenter *default_center = nil;
|
||||||
GSIArrayItem i[64];
|
GSIArrayItem i[64];
|
||||||
GSIArray_t b;
|
GSIArray_t b;
|
||||||
GSIArray a = &b;
|
GSIArray a = &b;
|
||||||
#if GS_WITH_GG
|
#if GS_WITH_GC
|
||||||
GSGarbageCollector *collector = [NSGarbageCollector defaultCollector];
|
NSGarbageCollector *collector = [NSGarbageCollector defaultCollector];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (name == nil)
|
if (name == nil)
|
||||||
|
@ -1045,22 +1045,22 @@ static NSNotificationCenter *default_center = nil;
|
||||||
object = CHEATGC(object);
|
object = CHEATGC(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialise static array to store copies of observers.
|
|
||||||
*/
|
|
||||||
GSIArrayInitWithZoneAndStaticCapacity(a, _zone, 64, i);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock the table of observations while we traverse it.
|
* Lock the table of observations while we traverse it.
|
||||||
*
|
*
|
||||||
* The table of observations contains weak pointers which are zeroed when
|
* The table of observations contains weak pointers which are zeroed when
|
||||||
* the observers get garbage collected. So to avoid consistency problems
|
* the observers get garbage collected. So to avoid consistency problems
|
||||||
* we disable gc while we copy all the observations we are interested in.
|
* we disable gc while we copy all the observations we are interested in.
|
||||||
|
* We use scanned memory in the array in the case where there are more
|
||||||
|
* than the 64 observers we allowed room for on the stack.
|
||||||
*/
|
*/
|
||||||
lockNCTable(TABLE);
|
#if GS_WITH_GC
|
||||||
#if GS_WITH_GG
|
GSIArrayInitWithZoneAndStaticCapacity(a, (NSZone*)1, 64, i);
|
||||||
[collector disable];
|
[collector disable];
|
||||||
|
#else
|
||||||
|
GSIArrayInitWithZoneAndStaticCapacity(a, _zone, 64, i);
|
||||||
#endif
|
#endif
|
||||||
|
lockNCTable(TABLE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find all the observers that specified neither NAME nor OBJECT.
|
* Find all the observers that specified neither NAME nor OBJECT.
|
||||||
|
@ -1142,10 +1142,10 @@ static NSNotificationCenter *default_center = nil;
|
||||||
* collection, safe in the knowledge that the observers we will be
|
* collection, safe in the knowledge that the observers we will be
|
||||||
* notifying won't get collected prematurely.
|
* notifying won't get collected prematurely.
|
||||||
*/
|
*/
|
||||||
#if GS_WITH_GG
|
unlockNCTable(TABLE);
|
||||||
|
#if GS_WITH_GC
|
||||||
[collector enable];
|
[collector enable];
|
||||||
#endif
|
#endif
|
||||||
unlockNCTable(TABLE);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now send all the notifications.
|
* Now send all the notifications.
|
||||||
|
|
|
@ -1924,7 +1924,10 @@ GSAssignZeroingWeakPointer(void **destination, void *source)
|
||||||
GC_unregister_disappearing_link(destination);
|
GC_unregister_disappearing_link(destination);
|
||||||
}
|
}
|
||||||
*destination = source;
|
*destination = source;
|
||||||
GC_general_register_disappearing_link(destination, source);
|
if (source != 0)
|
||||||
|
{
|
||||||
|
GC_general_register_disappearing_link(destination, source);
|
||||||
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue