mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Fix notification removal bug from last update
This commit is contained in:
parent
28ba7788ce
commit
b2e198cb0d
2 changed files with 14 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
|||
2024-11-12 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSNotificationCenter.m:
|
||||
Fix last update for case where we have a non-block notification.
|
||||
|
||||
2024-11-12 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/GNUstepBase/GSIMap.h:
|
||||
|
|
|
@ -141,8 +141,9 @@ struct NCTbl; /* Notification Center Table structure */
|
|||
typedef struct Obs {
|
||||
id observer; /* Object to receive message. */
|
||||
SEL selector; /* Method selector. */
|
||||
BOOL owner; /* If we own the observer. */
|
||||
int32_t retained; /* Retain count for structure. */
|
||||
struct Obs *next; /* Next item in linked list. */
|
||||
int retained; /* Retain count for structure. */
|
||||
struct NCTbl *link; /* Pointer back to chunk table */
|
||||
} Observation;
|
||||
|
||||
|
@ -296,6 +297,11 @@ obsNew(NCTable *t, SEL s, id o)
|
|||
obs->selector = s;
|
||||
obs->observer = o;
|
||||
|
||||
/* Instances of GSNotificationObserverClass are owned by the Observation
|
||||
* and must be explicitly released when the observation is removed.
|
||||
*/
|
||||
obs->owner = (GSNotificationObserverClass == object_getClass(o)) ? YES : NO;
|
||||
|
||||
return obs;
|
||||
}
|
||||
|
||||
|
@ -432,12 +438,10 @@ static void obsFree(Observation *o)
|
|||
{
|
||||
NCTable *t = o->link;
|
||||
|
||||
/* Instances of GSNotificationObserverClass are owned by the Observation
|
||||
* and must be explicitly released when the observation is removed.
|
||||
*/
|
||||
if (object_getClass(o->observer) == GSNotificationObserverClass)
|
||||
if (o->owner)
|
||||
{
|
||||
DESTROY(o->observer);
|
||||
o->owner = NO;
|
||||
}
|
||||
o->link = (NCTable*)t->freeList;
|
||||
t->freeList = o;
|
||||
|
|
Loading…
Reference in a new issue