bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFA] GDL2 EOModel _entities cache


From: David Ayers
Subject: Re: [RFA] GDL2 EOModel _entities cache
Date: Wed, 05 Feb 2003 01:23:56 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3a) Gecko/20021212

Hello again,

some of the recent patches have introduced some regressions in my testing envornment. Here is an updated patch to fix these, deal with the _entites issue, update some more NSDebugMLLogs and autorelease->AUTORELEASES.

I'll submit this upon approval or in a couple of days save objections.

Cheers,
Dave

Index: dev-libs/gdl2/ChangeLog
===================================================================
RCS file: /cvsroot/gnustep/gnustep/dev-libs/gdl2/ChangeLog,v
retrieving revision 1.34
diff -u -r1.34 ChangeLog
--- dev-libs/gdl2/ChangeLog     4 Feb 2003 15:16:47 -0000       1.34
+++ dev-libs/gdl2/ChangeLog     5 Feb 2003 00:18:55 -0000
@@ -1,3 +1,37 @@
+2003-02-04  David Ayers  <d.ayers@inode.at>
+
+       * EOAccess/EOModel.m
+       ([EOModel -encodeTableOfContentsIntoPropertyList:]),
+       ([EOModel -initWithPropertyList:owner:]),
+       ([EOModel -encodeIntoPropertyList:]), ([EOModel -addEntity:]),
+       ([EOModel -removeEntity:]), ([EOModel -beautifyNames]),
+       ([EOModel -setCreateMutableObjects:]):
+       Do not access _entities until cache is triggered. 
+       * EOAccess/EOModel.m
+       ([EOModel +findPathForModelNamed:]),
+       ([EOModel -gcDecrementRefCountOfContainedObjects]),
+       ([EOModel -storedProcedures]), ([EOModel -initWithContentsOfFile:]),
+       ([EOModel -initWithTableOfContentsPropertyList:path:]),
+       ([EOModel -initWithPropertyList:owner:]),
+       ([EOModel -_classDescriptionNeeded:]), ([EOModel -_entityForClass:]),
+       ([EOModel -_addEntityWithPropertyList:]), ([EOModel -_addEntity:]),
+       ([EOModel -_verifyBuiltEntityObject:named:]):
+       replaced NSDebugMLLog with EOFLOGObject/ClassLevelArgs. 
+       
+       * EOAccess/EOAdaptor.m ([EOAdaptor +adaptorWithName:]):
+       reinserted accessing adaptor class by principal class of bundle as
+       fallback in case EOAdaptorClassName isn't found.  Raise an
+       exception if the provided class is not a subclass of EOAdaptor.  
+       * EOAccess/EOAdaptor.m ([EOAdaptor +adaptorWithName:]),
+       ([EOAdaptor -fetchedValueForValue:attribute]),
+       ([EOAdaptor -fetchedValueForStringValue:attribute]):
+       replaced NSLog/NSDebugMLLog with EOFLOGObject/ClassLevelArgs. 
+       * EOAccess/EOAdaptor.m ([EOAdaptor +adaptorWithModel:]),
+       ([EOAdaptor +adaptorWithName:]),
+       ([EOAdaptor +availableAdaptorNames]):
+       replaced autorelease with AUTORELEASE(). 
+       
+
 2003-02-04  Stephane Corthesy  <stephane@sente.ch>
 
        * Tools/eoutil.m: implemented.
@@ -207,7 +241,7 @@
        * EOControl/EODebug.m:
                o include NSDebug.h
        
-2003-01-21  David Ayers <d.ayers@inode.at>
+2003-01-21  David Ayers  <d.ayers@inode.at>
 
        * EOControl/EOQualifier.m ([EOQualifier +allQualifierOperators]): 
        ([EOQualifier +relationalQualifierOperators]): 
@@ -219,7 +253,7 @@
        * EOControl/EOObserver.m: Added implementation for EODelayedObserver
        and EODelayedObserverQueue.
 
-2003-01-16  David Ayers <d.ayers@inode.at>
+2003-01-16  David Ayers  <d.ayers@inode.at>
 
        * EOAdaptors/Postgres95/Postgres95Adaptor.m:
        Added import of NSDebug.h/EODebug.h
Index: dev-libs/gdl2/EOAccess/EOAdaptor.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/dev-libs/gdl2/EOAccess/EOAdaptor.m,v
retrieving revision 1.7
diff -u -r1.7 EOAdaptor.m
--- dev-libs/gdl2/EOAccess/EOAdaptor.m  3 Feb 2003 14:52:51 -0000       1.7
+++ dev-libs/gdl2/EOAccess/EOAdaptor.m  5 Feb 2003 00:18:55 -0000
@@ -106,8 +106,7 @@
           Class adaptorClass = NSClassFromString([NSString stringWithFormat: 
@"%@%@", adaptorName, @"Adaptor"]);
 
           if(adaptorClass)
-            adaptor = [[[adaptorClass alloc] initWithName: adaptorName]
-                        autorelease];
+            adaptor = AUTORELEASE([[adaptorClass alloc] initWithName: 
adaptorName]);
           else
             adaptor = [self adaptorWithName: adaptorName];
 
@@ -163,29 +162,29 @@
       env = [pInfo environment];
       paths = [NSMutableArray array];
 
-      user = [[[env objectForKey: @"GNUSTEP_USER_ROOT"]
-               mutableCopy] autorelease];
+      user = AUTORELEASE([[env objectForKey: @"GNUSTEP_USER_ROOT"] 
+                          mutableCopy]);
       [user appendString: @"/Libraries/Frameworks"];
 
       if (user)
        [paths addObject: user];
 
-      local = [[[env objectForKey: @"GNUSTEP_LOCAL_ROOT"]
-                mutableCopy] autorelease];
+      local = AUTORELEASE([[env objectForKey: @"GNUSTEP_LOCAL_ROOT"]
+                           mutableCopy]);
       [local appendString: @"/Libraries/Frameworks"];
 
       if (local)
        [paths addObject: local];
 
-      local = [[[env objectForKey: @"GNUSTEP_LOCAL_ROOT"]
-         mutableCopy] autorelease];
+      local = AUTORELEASE([[env objectForKey: @"GNUSTEP_LOCAL_ROOT"]
+         mutableCopy]);
       [local appendString: @"/Library/Frameworks"];
 
       if (local)
        [paths addObject: local];
 
-      system = [[[env objectForKey: @"GNUSTEP_SYSTEM_ROOT"]
-                 mutableCopy] autorelease];
+      system = AUTORELEASE([[env objectForKey: @"GNUSTEP_SYSTEM_ROOT"]
+                 mutableCopy]);
       [system appendString: @"/Libraries/Frameworks"];
 
       if (system)
@@ -226,23 +225,40 @@
      identifies the actual adaptor class from the bundle. */
 
   if(![bundle isLoaded])
-    NSLog(@"Loaded %@? %@", bundle, ([bundle load]? @"YES":@"NO"));
+    EOFLOGClassLevelArgs(@"gsdb", @"Loaded %@? %@", bundle, ([bundle load]? 
@"YES":@"NO"));
 
   adaptorClassName = [[bundle infoDictionary] objectForKey: 
@"EOAdaptorClassName"];
 
-  NSLog(@"adaptorClassName is %@", adaptorClassName);
+  EOFLOGClassLevelArgs(@"gsdb", @"adaptorClassName is %@", adaptorClassName);
 
   adaptorClass = NSClassFromString(adaptorClassName);
 
-  if(!adaptorClass)
-    [NSException raise: NSInvalidArgumentException
-                 format: @"%@ -- %@ 0x%x: the adaptor bundle '%@' doesn't 
contain a principal class",
-                 NSStringFromSelector(_cmd),
-                 NSStringFromClass([self class]),
-                 self,
-                 adaptorName];
+  if (adaptorClass == Nil)
+    {
+      adaptorClass = [bundle principalClass];
+    }
+
+  if(adaptorClass == Nil)
+    {
+      [NSException raise: NSInvalidArgumentException
+                  format: @"%@ -- %@ 0x%x: value of EOAdaptorClassName '%@' is 
not a valid class and bundle does not contain a principal class",
+                  NSStringFromSelector(_cmd),
+                  NSStringFromClass([self class]),
+                  self,
+                  adaptorName];
+    }
+      
+  if ([adaptorClass isSubclassOfClass: [self class]] == NO)
+    {
+      [NSException raise: NSInvalidArgumentException
+                  format: @"%@ -- %@ 0x%x: principal class is not a subclass 
of EOAdaptor:%@",
+                  NSStringFromSelector(_cmd),
+                  NSStringFromClass([self class]),
+                  self,
+                  NSStringFromClass([adaptorClass class])];
+    }
 
-  return [[[adaptorClass alloc] initWithName: adaptorName] autorelease];
+  return AUTORELEASE([[adaptorClass alloc] initWithName: adaptorName]);
 }
 
 + (void)setExpressionClassName: (NSString *)sqlExpressionClassName
@@ -268,7 +284,7 @@
   NSArray       *fileNames;
   NSEnumerator  *filesEnum;
   NSString      *fileName;
-  NSMutableArray *adaptorNames = [[NSMutableArray new] autorelease];
+  NSMutableArray *adaptorNames = AUTORELEASE([NSMutableArray new]);
   
   EOFLOGObjectFnStartOrCond2(@"AdaptorLevel", @"EOAdaptor");
 
@@ -480,8 +496,8 @@
   SEL valueFactoryMethod;
 
   EOFLOGObjectFnStart();
-  NSDebugMLLog(@"gsdb", @"value=%@", value);
-  NSDebugMLLog(@"gsdb", @"attribute=%@", attribute);
+  EOFLOGObjectLevelArgs(@"gsdb", @"value=%@", value);
+  EOFLOGObjectLevelArgs(@"gsdb", @"attribute=%@", attribute);
 
   valueFactoryMethod = [attribute valueFactoryMethod];
 
@@ -505,7 +521,7 @@
         value = [self fetchedValueForDataValue: value
                       attribute: attribute];
 
-      NSDebugMLLog(@"gsdb",@"value=%@",value);
+      EOFLOGObjectLevelArgs(@"gsdb",@"value=%@",value);
     }
 
   if(_delegateRespondsTo.processValue)
@@ -513,7 +529,7 @@
                        fetchedValueForValue: value
                        attribute: attribute];
 
-  NSDebugMLLog(@"gsdb", @"value=%@", value);
+  EOFLOGObjectLevelArgs(@"gsdb", @"value=%@", value);
   EOFLOGObjectFnStop();
 
   return value;
@@ -525,8 +541,8 @@
   NSString *resultValue = nil;
 
   EOFLOGObjectFnStart();
-  NSDebugMLLog(@"gsdb", @"value=%@", value);
-  NSDebugMLLog(@"gsdb", @"attribute=%@", attribute);
+  EOFLOGObjectLevelArgs(@"gsdb", @"value=%@", value);
+  EOFLOGObjectLevelArgs(@"gsdb", @"attribute=%@", attribute);
     
   if([value length]>0)
     {
Index: dev-libs/gdl2/EOAccess/EOModel.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/dev-libs/gdl2/EOAccess/EOModel.m,v
retrieving revision 1.9
diff -u -r1.9 EOModel.m
--- dev-libs/gdl2/EOAccess/EOModel.m    3 Feb 2003 14:52:52 -0000       1.9
+++ dev-libs/gdl2/EOAccess/EOModel.m    5 Feb 2003 00:18:55 -0000
@@ -95,26 +95,28 @@
   NSArray *paths = 
NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory, NSAllDomainsMask, 
YES);
 
   tmpModelName = [modelName lastPathComponent];
-  NSDebugMLLog(@"gsdb", @"modelName=%@ tmpModelName=%@",
-              modelName, tmpModelName);
+  EOFLOGClassLevelArgs(@"gsdb", @"modelName=%@ tmpModelName=%@",
+                      modelName, tmpModelName);
 
   tmpPath = [[modelName stringByStandardizingPath]
               stringByDeletingLastPathComponent]; 
-  NSDebugMLLog(@"gsdb", @"modelName=%@ tmpPath=%@", modelName, tmpPath);
+  EOFLOGClassLevelArgs(@"gsdb", @"modelName=%@ tmpPath=%@",
+                       modelName, tmpPath);
 
   bundle = [NSBundle mainBundle];
   modelPath = [bundle pathForResource: modelName
                       ofType: @"eomodel"];
 
-  NSDebugMLLog(@"gsdb", @"modelName=%@ modelPath=%@", modelName, modelPath);
+  EOFLOGClassLevelArgs(@"gsdb", @"modelName=%@ modelPath=%@",
+                       modelName, modelPath);
 
   if (!modelPath)
     {
       modelPath = [bundle pathForResource: modelName
                           ofType: @"eomodeld"];
 
-      NSDebugMLLog(@"gsdb", @"modelName=%@ modelPath=%@",
-                  modelName, modelPath);
+      EOFLOGClassLevelArgs(@"gsdb", @"modelName=%@ modelPath=%@",
+                           modelName, modelPath);
 
       if (!modelPath)
         {
@@ -127,23 +129,24 @@
           if ([[tmpModelName pathExtension] length] != 0)
             tmpModelName = [tmpModelName stringByDeletingPathExtension]; 
           
-          NSDebugMLLog(@"gsdb", @"modelName=%@ tmpPath=%@ tmpModelName=%@",
-                      modelName, tmpPath, tmpModelName);
+          EOFLOGClassLevelArgs(@"gsdb",
+                               @"modelName=%@ tmpPath=%@ tmpModelName=%@",
+                               modelName, tmpPath, tmpModelName);
 
           bundle = [NSBundle bundleWithPath: tmpPath];
           
           modelPath = [bundle pathForResource: tmpModelName
                               ofType: @"eomodel"];
 
-          NSDebugMLLog(@"gsdb", @"modelName=%@ modelPath=%@",
-                      modelName, modelPath);
+          EOFLOGClassLevelArgs(@"gsdb", @"modelName=%@ modelPath=%@",
+                               modelName, modelPath);
 
           if (!modelPath)
             {          
               modelPath = [bundle pathForResource: tmpModelName
                                   ofType: @"eomodeld"];
-              NSDebugMLLog(@"gsdb", @"modelName=%@ modelPath=%@",
-                          modelName, modelPath);
+              EOFLOGClassLevelArgs(@"gsdb", @"modelName=%@ modelPath=%@",
+                                   modelName, modelPath);
 
               if (!modelPath)
                 {
@@ -151,23 +154,27 @@
 
                   for (i = 0; !modelPath && pathCount < i; i++)
                     {
-                      NSDebugMLLog(@"gsdb", @"Trying path:%@", [paths 
objectAtIndex:i]);
+                      EOFLOGClassLevelArgs(@"gsdb",
+                                           @"Trying path:%@",
+                                           [paths objectAtIndex:i]);
 
                       bundle = [NSBundle bundleWithPath: [paths 
objectAtIndex:i]];
                       
                       modelPath = [bundle pathForResource: modelName
                                           ofType: @"eomodel"];
 
-                      NSDebugMLLog(@"gsdb", @"modelName=%@ modelPath=%@",
-                                  modelName, modelPath);
+                      EOFLOGClassLevelArgs(@"gsdb",
+                                           @"modelName=%@ modelPath=%@",
+                                           modelName, modelPath);
 
                       if (!modelPath)
                         {
                           modelPath = [bundle pathForResource: modelName
                                               ofType: @"eomodeld"];
 
-                          NSDebugMLLog(@"gsdb", @"modelName=%@ modelPath=%@",
-                                      modelName, modelPath);
+                          EOFLOGClassLevelArgs(@"gsdb",
+                                               @"modelName=%@ modelPath=%@",
+                                               modelName, modelPath);
                         }
                     }
                 }
@@ -382,13 +389,14 @@
       NSArray *storedProcedures = nil;
       NSArray *storedProcedureNames = [self storedProcedureNames];
 
-      NSDebugMLLog(@"gsdb", @"storedProcedureNames=%@", storedProcedureNames);
+      EOFLOGObjectLevelArgs(@"gsdb", @"storedProcedureNames=%@",
+                           storedProcedureNames);
 
       storedProcedures = [self resultsOfPerformingSelector:
                                 @selector(storedProcedureNamed:)
                               withEachObjectInArray: storedProcedureNames];
 
-      NSDebugMLLog(@"gsdb", @"storedProcedures=%@", storedProcedures);
+      EOFLOGObjectLevelArgs(@"gsdb", @"storedProcedures=%@", storedProcedures);
 
       ASSIGN(_storedProcedures, [GCArray arrayWithArray:storedProcedures]);
 /*      [self performSelector:@selector(storedProcedureNamed:)
@@ -513,7 +521,7 @@
 
       fileContents = [NSString stringWithContentsOfFile: indexPath];
       propList = [fileContents propertyList];
-      NSDebugMLLog(@"gsdb", @"propList=%@", propList);
+      EOFLOGObjectLevelArgs(@"gsdb", @"propList=%@", propList);
       NSAssert1(propList!=nil, @"Model at path %@ is invalid", indexPath);
 
       self = [self initWithTableOfContentsPropertyList: propList
@@ -593,11 +601,12 @@
           NSArray  *entities = nil;
           int i, count = 0;
 
-          NSDebugMLLog(@"gsdb", @"tableOfContents=%@", tableOfContents);
+          EOFLOGObjectLevelArgs(@"gsdb", @"tableOfContents=%@",
+                               tableOfContents);
 
          /* The call to _setPath: also sets the name implicitly. */
           [self _setPath: [isa _formatModelPath: path checkFileSystem: YES]];
-          NSDebugMLLog(@"gsdb", @"name=%@ path=%@", _name, _path);
+          EOFLOGObjectLevelArgs(@"gsdb", @"name=%@ path=%@", _name, _path);
 
           versionString = [tableOfContents objectForKey: @"EOModelVersion"];
           if (versionString)
@@ -704,7 +713,8 @@
   if (_docComment)
     [propertyList setObject: _docComment forKey: @"docComment"];
 
-  count = [_entities count];
+  /* Do not access _entities until cache is triggered */
+  count = [[self entities] count];
   entitiesArray = [NSMutableArray arrayWithCapacity: count];
   [propertyList setObject: entitiesArray forKey: @"entities"];
 
@@ -775,7 +785,8 @@
               NSDictionary *plist;
           
               plist = [propListEntities objectAtIndex: i];
-              NSDebugMLLog(@"gsdb", @"plist=%@ [%@]", plist, [plist class]);
+              EOFLOGObjectLevelArgs(@"gsdb", @"plist=%@ [%@]",
+                                   plist, [plist class]);
           
               if (_version >= 2)
                 {
@@ -796,7 +807,8 @@
               [self addEntity: entity];
             }
 
-          enumerator = [_entities objectEnumerator];
+          /* Do not access _entities until cache is triggered */
+          enumerator = [[self entities] objectEnumerator];
           while ((entity = [enumerator nextObject]))
             {
               NS_DURING
@@ -891,7 +903,8 @@
   if (_docComment)
     [propertyList setObject: _docComment forKey: @"docComment"];
 
-  count = [_entities count];
+  /* Do not access _entities until cache is triggered */
+  count = [[self entities] count];
 
   if (count > 0)
     {
@@ -938,7 +951,7 @@
 
   notificationName = [notification name];
 
-  NSDebugMLLog(@"gsdb", @"notificationName=%@", notificationName);
+  EOFLOGObjectLevelArgs(@"gsdb", @"notificationName=%@", notificationName);
 
   if ([notificationName
        isEqualToString: EOClassDescriptionNeededForClassNotification])
@@ -948,7 +961,8 @@
       EOEntity *entity = nil;
       NSString *entityClassName = nil;
 
-      NSDebugMLLog(@"gsdb", @"notification=%@ aClass=%@", notification, 
aClass);
+      EOFLOGObjectLevelArgs(@"gsdb", @"notification=%@ aClass=%@",
+                           notification, aClass);
       NSAssert(aClass, @"No class");
 
       entity = [self _entityForClass: aClass];
@@ -961,16 +975,19 @@
       else
         {
           classDescription = [entity classDescriptionForInstances];
-          NSDebugMLLog(@"gsdb", @"classDescription=%@", classDescription);
+          EOFLOGObjectLevelArgs(@"gsdb", @"classDescription=%@",
+                               classDescription);
 
           entityClassName = [entity className];
-          NSDebugMLLog(@"gsdb",@"entityClassName=%@",entityClassName);
+          EOFLOGObjectLevelArgs(@"gsdb",@"entityClassName=%@",entityClassName);
 
           [EOClassDescription registerClassDescription: classDescription
                               forClass: NSClassFromString(entityClassName)];
 
           /*      classDescription = [[EOClassDescription new] autorelease];
-                  NSDebugMLLog(@"gsdb", @"classDescription=%@ aClass=%@", 
classDescription, aClass);
+                  EOFLOGObjectLevelArgs(@"gsdb",
+                                       @"classDescription=%@ aClass=%@",
+                                       classDescription, aClass);
                   [EOClassDescription registerClassDescription: 
classDescription
                   forClass: aClass];
           */
@@ -985,8 +1002,8 @@
       EOEntity *entity;
       NSString *entityClassName;
 
-      NSDebugMLLog(@"gsdb", @"notification=%@", notification);
-      NSDebugMLLog(@"gsdb", @"entityName=%@", entityName);
+      EOFLOGObjectLevelArgs(@"gsdb", @"notification=%@", notification);
+      EOFLOGObjectLevelArgs(@"gsdb", @"entityName=%@", entityName);
 
       NSAssert(entityName, @"No entity name");//??
 
@@ -994,10 +1011,10 @@
       NSAssert1(entity, @"No entity named %@", entityName);//??
 
       classDescription = [entity classDescriptionForInstances];
-      NSDebugMLLog(@"gsdb", @"classDescription=%@", classDescription);
+      EOFLOGObjectLevelArgs(@"gsdb", @"classDescription=%@", classDescription);
 
       entityClassName = [entity className];
-      NSDebugMLLog(@"gsdb", @"entityClassName=%@", entityClassName);
+      EOFLOGObjectLevelArgs(@"gsdb", @"entityClassName=%@", entityClassName);
 
       [EOClassDescription registerClassDescription: classDescription
                           forClass: NSClassFromString(entityClassName)];//??
@@ -1055,26 +1072,27 @@
   NSAssert(_entitiesByClass, @"No _entitiesByClass");
 
   className = NSStringFromClass(aClass);
-  NSDebugMLLog(@"gsdb", @"className=%@", className);
+  EOFLOGObjectLevelArgs(@"gsdb", @"className=%@", className);
 
   entity = NSMapGet(_entitiesByClass, className);
-  NSDebugMLLog(@"gsdb", @"entity class=%@", [entity class]);
+  EOFLOGObjectLevelArgs(@"gsdb", @"entity class=%@", [entity class]);
 
   if (entity)
     {
       entity = [self _verifyBuiltEntityObject: entity
                      named: nil];
-      NSDebugMLLog(@"gsdb", @"entity=%@", entity);
+      EOFLOGObjectLevelArgs(@"gsdb", @"entity=%@", entity);
     }
   else
     {
-      NSDebugMLLog(@"gsdb", @"entity for class named=%@ not found", className);
-      NSDebugMLLog(@"gsdb", @"entities class names=%@",
-                  NSAllMapTableKeys(_entitiesByClass));
-      NSDebugMLLog(@"gsdb", @"entities entities names=%@",
-                  NSAllMapTableValues(_entitiesByClass));
-      NSDebugMLLog(@"gsdb", @"entities map=%@",
-                  NSStringFromMapTable(_entitiesByClass));
+      EOFLOGObjectLevelArgs(@"gsdb", @"entity for class named=%@ not found",
+                           className);
+      EOFLOGObjectLevelArgs(@"gsdb", @"entities class names=%@",
+                           NSAllMapTableKeys(_entitiesByClass));
+      EOFLOGObjectLevelArgs(@"gsdb", @"entities entities names=%@",
+                           NSAllMapTableValues(_entitiesByClass));
+      EOFLOGObjectLevelArgs(@"gsdb", @"entities map=%@",
+                           NSStringFromMapTable(_entitiesByClass));
     }
 
   EOFLOGObjectFnStop();
@@ -1132,7 +1150,7 @@
   EOEntity *entity = nil;
 
   NSAssert(propertyList, @"no propertyList");
-  NSDebugMLLog(@"gsdb", @"propertyList=%@", propertyList);
+  EOFLOGObjectLevelArgs(@"gsdb", @"propertyList=%@", propertyList);
 
   entity = [EOEntity entityWithPropertyList: propertyList
                     owner: self];
@@ -1184,7 +1202,7 @@
   NSString *entityClassName;
 
   NSAssert(entity, @"No entity to add");
-  NSDebugMLLog(@"gsdb", @"model _addEntity=%@", [entity name]);
+  EOFLOGObjectLevelArgs(@"gsdb", @"model _addEntity=%@", [entity name]);
 
   entityClassName = [entity className];
   NSAssert2(entityClassName, @"Entity %p named %@ has no class name",
@@ -1279,11 +1297,12 @@
                  self,
                  entityName];
 
+  /* Do not access _entities until cache is triggered */
   if ([self createsMutableObjects])
-    [(GCMutableArray *)_entities addObject: entity];
+    [(GCMutableArray *)[self entities] addObject: entity];
   else
     {
-      id       e = [[GCMutableArray alloc] initWithArray: _entities];
+      id       e = [[GCMutableArray alloc] initWithArray: [self entities]];
 
       [e addObject: entity];
       ASSIGNCOPY(_entities, e);
@@ -1318,11 +1337,12 @@
   NSAssert1(className, @"No className in %@", entity);
   NSMapRemove(_entitiesByClass, className);
 
+  /* Do not access _entities until cache is triggered */
   if ([self createsMutableObjects])
-    [(GCMutableArray *)_entities removeObject: entity];
+    [(GCMutableArray *)[self entities] removeObject: entity];
   else
     {
-      id       e = [[GCMutableArray alloc] initWithArray: _entities];
+      id       e = [[GCMutableArray alloc] initWithArray: [self entities]];
 
       [e removeObject: entity];
       ASSIGNCOPY(_entities, e);
@@ -1447,7 +1467,8 @@
          [self setName: newString];
 
          // Entites
-         if (_entities && (count = [_entities count]))
+         /* Do not access _entities until cache is triggered */
+         if ([self entities] && (count = [_entities count]))
            {
              for (i = 0; i < count; i++)
                [(EOEntity *)[_entities objectAtIndex:i] beautifyName];
@@ -1541,10 +1562,11 @@
     {
       _flags.createsMutableObjects = flag;
       
+      /* Do not access _entities until cache is triggered */
       if (_flags.createsMutableObjects)
-       _entities = [[GCMutableArray alloc] initWithArray:[_entities 
autorelease] copyItems:NO];
+       _entities = [[GCMutableArray alloc] initWithArray:[[self entities] 
autorelease] copyItems:NO];
       else
-       _entities = [[GCArray alloc] initWithArray:[_entities autorelease] 
copyItems:NO];
+       _entities = [[GCArray alloc] initWithArray:[[self entities] 
autorelease] copyItems:NO];
     }
 }
 
@@ -1566,27 +1588,28 @@
           NSString *plistPathName = nil;
           NSDictionary *propList = nil;
 
-          NSDebugMLLog(@"gsdb", @"name=%@", name);
+          EOFLOGObjectLevelArgs(@"gsdb", @"name=%@", name);
 
           if (!name && [entity isKindOfClass: [NSDictionary class]])
             name = [entity objectForKey: @"name"];
 
-          NSDebugMLLog(@"gsdb", @"name=%@", name);
+          EOFLOGObjectLevelArgs(@"gsdb", @"name=%@", name);
           NSAssert1(name, @"No name for entity %@", entity);
-          NSDebugMLLog(@"gsdb", @"[self path]=%@", [self path]);
+          EOFLOGObjectLevelArgs(@"gsdb", @"[self path]=%@", [self path]);
 
           basePath = [self path]; 
           [RETAIN(entity) autorelease]; //so it won't be lost in _removeEntity
 
-          NSDebugMLLog(@"gsdb", @"basePath =%@", basePath);
+          EOFLOGObjectLevelArgs(@"gsdb", @"basePath =%@", basePath);
 
           plistPathName = [[basePath stringByAppendingPathComponent: name]
                            stringByAppendingPathExtension: @"plist"];
 
-          NSDebugMLLog(@"gsdb", @"entity plistPathName =%@", plistPathName);
+          EOFLOGObjectLevelArgs(@"gsdb", @"entity plistPathName =%@",
+                               plistPathName);
 
           propList = [NSDictionary dictionaryWithContentsOfFile: 
plistPathName];
-          NSDebugMLLog(@"gsdb", @"entity propList=%@", propList);
+          EOFLOGObjectLevelArgs(@"gsdb", @"entity propList=%@", propList);
 
           if (!propList)
             {
@@ -1605,7 +1628,7 @@
             }
 
           [self _removeEntity: entity];
-          NSDebugMLLog(@"gsdb", @"entity propList=%@", propList);
+          EOFLOGObjectLevelArgs(@"gsdb", @"entity propList=%@", propList);
 
           entity = [self _addEntityWithPropertyList: propList];
         }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]