mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
finalize KV observations
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27639 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e82bd33ab1
commit
399e2f9b38
3 changed files with 10 additions and 5 deletions
|
@ -260,9 +260,10 @@ GSMakeWeakPointer(Class class, const char *iVarName);
|
|||
* object. Apart from that case, a source needs to be garbage collectable for
|
||||
* this function to work, and using a non-garbage collectable value will
|
||||
* cause the function to return NO.<br />
|
||||
* The destination object (watching the source object) must also be memory
|
||||
* allocated by the garbage colleector, and if it is not the function will
|
||||
* return NO.<br />
|
||||
* If the destination object (the weak pointer watching the source object)
|
||||
* belongs to a chunk of memory which may be collected before the source
|
||||
* object is collected, it is important that it is finalised and the
|
||||
* finalisation code assigns zero to the pointer.<br />
|
||||
* If garbage collection is not in use, this function performs a simple
|
||||
* assignment returning YES, unless destination is null in which case it
|
||||
* returns NO.
|
||||
|
|
|
@ -810,6 +810,10 @@ replacementForClass(Class c)
|
|||
{
|
||||
GSMakeWeakPointer(self, "observer");
|
||||
}
|
||||
- (void) finalize
|
||||
{
|
||||
GSAssignZeroingWeakPointer((void**)&observer, nil);
|
||||
}
|
||||
#endif
|
||||
@end
|
||||
|
||||
|
|
|
@ -1910,9 +1910,9 @@ GSMakeWeakPointer(Class class, const char *iVarName)
|
|||
BOOL
|
||||
GSAssignZeroingWeakPointer(void **destination, void *source)
|
||||
{
|
||||
if (GC_base(destination) == 0)
|
||||
if (destination == 0)
|
||||
{
|
||||
return NO; // Destination is not in garbage collection system.
|
||||
return NO; // Bad destination pointer
|
||||
}
|
||||
if (*destination == source)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue