mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-02 01:21:08 +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
9c5d4cd19e
commit
03c8a8fd7d
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
|
* 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
|
* this function to work, and using a non-garbage collectable value will
|
||||||
* cause the function to return NO.<br />
|
* cause the function to return NO.<br />
|
||||||
* The destination object (watching the source object) must also be memory
|
* If the destination object (the weak pointer watching the source object)
|
||||||
* allocated by the garbage colleector, and if it is not the function will
|
* belongs to a chunk of memory which may be collected before the source
|
||||||
* return NO.<br />
|
* 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
|
* If garbage collection is not in use, this function performs a simple
|
||||||
* assignment returning YES, unless destination is null in which case it
|
* assignment returning YES, unless destination is null in which case it
|
||||||
* returns NO.
|
* returns NO.
|
||||||
|
|
|
@ -810,6 +810,10 @@ replacementForClass(Class c)
|
||||||
{
|
{
|
||||||
GSMakeWeakPointer(self, "observer");
|
GSMakeWeakPointer(self, "observer");
|
||||||
}
|
}
|
||||||
|
- (void) finalize
|
||||||
|
{
|
||||||
|
GSAssignZeroingWeakPointer((void**)&observer, nil);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -1910,9 +1910,9 @@ GSMakeWeakPointer(Class class, const char *iVarName)
|
||||||
BOOL
|
BOOL
|
||||||
GSAssignZeroingWeakPointer(void **destination, void *source)
|
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)
|
if (*destination == source)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue