mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-02-20 18:12:04 +00:00
* EOAccess/EOPrivate.h: Add notification constants.
* EOAccess/EOAttribute.m: Observe EOEntity's notification. * EOAccess/EORelationship.m: Observe EOEntity's notification. * EOAccess/EOModel.m: Post notification when deallocating. * EOAccess/EOEntity.m: Post notification when deallocating, and observe EOModels notification. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@23946 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
da74a77858
commit
f9f1fdb6d3
6 changed files with 75 additions and 0 deletions
|
@ -1,3 +1,12 @@
|
|||
2006-10-22 Matt Rice <ratmice@yahoo.com>
|
||||
|
||||
* EOAccess/EOPrivate.h: Add notification constants.
|
||||
* EOAccess/EOAttribute.m: Observe EOEntity's notification.
|
||||
* EOAccess/EORelationship.m: Observe EOEntity's notification.
|
||||
* EOAccess/EOModel.m: Post notification when deallocating.
|
||||
* EOAccess/EOEntity.m: Post notification when deallocating, and
|
||||
observe EOModels notification.
|
||||
|
||||
2006-10-14 Matt Rice <ratmice@yahoo.com>
|
||||
|
||||
* EOAccess/EOAttribute.m: Remove usage of GCObject, and its subclasses.
|
||||
|
|
|
@ -53,6 +53,7 @@ RCS_ID("$Id$")
|
|||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSCalendarDate.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#else
|
||||
#include <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
@ -100,6 +101,24 @@ RCS_ID("$Id$")
|
|||
return [[[self alloc] initWithPropertyList: propertyList
|
||||
owner: owner] autorelease];
|
||||
}
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(_entityWillDeallocate:)
|
||||
name:GDL2EntityWillDeallocateNotification
|
||||
object:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) _entityWillDeallocate:(NSNotification *)notif
|
||||
{
|
||||
if (_parent == [[notif object] pointerValue])
|
||||
_parent = nil;
|
||||
}
|
||||
|
||||
- (id) initWithPropertyList: (NSDictionary *)propertyList
|
||||
owner: (id)owner
|
||||
|
@ -371,6 +390,7 @@ RCS_ID("$Id$")
|
|||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
DESTROY(_name);
|
||||
DESTROY(_prototype);
|
||||
DESTROY(_columnName);
|
||||
|
|
|
@ -53,6 +53,7 @@ RCS_ID("$Id$")
|
|||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSObjCRuntime.h>
|
||||
#include <Foundation/NSZone.h>
|
||||
#else
|
||||
|
@ -87,6 +88,9 @@ RCS_ID("$Id$")
|
|||
#include "EOEntityPriv.h"
|
||||
#include "EOAttributePriv.h"
|
||||
|
||||
NSString *GDL2EntityWillDeallocateNotification =
|
||||
@"GDL2EntityWillDeallocateNotification";
|
||||
|
||||
@interface EOModel (Privat)
|
||||
- (void)_updateCache;
|
||||
@end
|
||||
|
@ -514,13 +518,27 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
|
|||
_attributes = [NSMutableArray new];
|
||||
_subEntities = [NSMutableArray new];
|
||||
[self setCreateMutableObjects: YES];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(_modelWillDeallocate:)
|
||||
name:GDL2ModelWillDeallocateNotification
|
||||
object:nil];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) _modelWillDeallocate:(NSNotification *)notif
|
||||
{
|
||||
if (_model == [[notif object] pointerValue])
|
||||
_model = nil;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:GDL2EntityWillDeallocateNotification
|
||||
object:[NSValue valueWithPointer:self]];
|
||||
DESTROY(_attributes);
|
||||
DESTROY(_name);
|
||||
DESTROY(_className);
|
||||
|
|
|
@ -83,6 +83,7 @@ RCS_ID("$Id$")
|
|||
#define DEFAULT_MODEL_VERSION 2
|
||||
|
||||
NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
|
||||
NSString *GDL2ModelWillDeallocateNotification = @"GDL2ModelWillDeallocateNotification";
|
||||
|
||||
@interface EOModel (EOModelPrivate)
|
||||
|
||||
|
@ -248,6 +249,9 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
|
|||
- (void) dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:GDL2ModelWillDeallocateNotification
|
||||
object:[NSValue valueWithPointer:self]];
|
||||
|
||||
if (_entitiesByClass)
|
||||
{
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include "../EOControl/EOPrivate.h"
|
||||
|
||||
@class EODatabaseContext;
|
||||
GDL2ACCESS_EXPORT NSString *GDL2EntityWillDeallocateNotification;
|
||||
GDL2ACCESS_EXPORT NSString *GDL2ModelWillDeallocateNotification;
|
||||
|
||||
// ==== Classes ====
|
||||
GDL2ACCESS_EXPORT Class GDL2_EODatabaseContextClass;
|
||||
|
|
|
@ -43,6 +43,8 @@ RCS_ID("$Id$")
|
|||
#include <Foundation/NSUtilities.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#else
|
||||
#include <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
@ -102,6 +104,11 @@ RCS_ID("$Id$")
|
|||
_sourceToDestinationKeyMap = [NSDictionary new];
|
||||
_joins = [GCMutableArray new];
|
||||
*/
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(_entityWillDeallocate:)
|
||||
name:GDL2EntityWillDeallocateNotification
|
||||
object:nil];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -109,6 +116,7 @@ RCS_ID("$Id$")
|
|||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
DESTROY(_name);
|
||||
DESTROY(_qualifier);
|
||||
DESTROY(_sourceNames);
|
||||
|
@ -2387,4 +2395,18 @@ attr entity
|
|||
EOFLOGObjectFnStop();
|
||||
}
|
||||
|
||||
- (void) _entityWillDeallocate:(NSNotification *)notif
|
||||
{
|
||||
id entity = [[notif object] pointerValue];
|
||||
|
||||
if (entity == _entity)
|
||||
{
|
||||
_entity = nil;
|
||||
}
|
||||
if (entity == _destination)
|
||||
{
|
||||
_destination = nil;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue