@@ -353,37 +353,53 @@ -(id)singlePrimaryKeyValue
353
353
+(LKModelInfos *)getModelInfos
354
354
{
355
355
static __strong NSMutableDictionary * oncePropertyDic;
356
+ static __strong NSRecursiveLock * lock;
357
+
356
358
static dispatch_once_t onceToken;
357
359
dispatch_once (&onceToken, ^{
360
+ lock = [[NSRecursiveLock alloc ]init];
358
361
oncePropertyDic = [[NSMutableDictionary alloc ]initWithCapacity:8 ];
359
362
});
360
363
361
364
LKModelInfos* infos;
362
- @synchronized (self)
365
+ [lock lock ];
366
+
367
+ infos = [oncePropertyDic objectForKey: NSStringFromClass (self )];
368
+ if (infos == nil )
363
369
{
364
- infos = [oncePropertyDic objectForKey: NSStringFromClass (self )];
365
- if (infos == nil )
370
+ NSMutableArray * pronames = [NSMutableArray array ];
371
+ NSMutableArray * protypes = [NSMutableArray array ];
372
+ NSDictionary * keymapping = [self getTableMapping ];
373
+ [self getSelfPropertys: pronames protypes: protypes];
374
+
375
+ NSArray * pkArray = [self getPrimaryKeyUnionArray ];
376
+ if (pkArray.count == 0 )
366
377
{
367
- NSMutableArray * pronames = [NSMutableArray array ];
368
- NSMutableArray * protypes = [NSMutableArray array ];
369
- NSDictionary * keymapping = [self getTableMapping ];
370
- [self getSelfPropertys: pronames protypes: protypes];
371
-
372
- NSArray * pkArray = [self getPrimaryKeyUnionArray ];
373
- if (pkArray.count == 0 )
378
+ pkArray = nil ;
379
+ NSString * pk = [self getPrimaryKey ];
380
+ if ([LKDBUtils checkStringIsEmpty: pk] == NO )
374
381
{
375
- pkArray = nil ;
376
- NSString * pk = [self getPrimaryKey ];
377
- if ([LKDBUtils checkStringIsEmpty: pk] == NO )
382
+ pkArray = [NSArray arrayWithObject: pk];
383
+ }
384
+ }
385
+ if ([self isContainParent ] && [self superclass ] != [NSObject class ])
386
+ {
387
+ LKModelInfos* superInfos = [[self superclass ] getModelInfos ];
388
+ for (int i=0 ; i<superInfos.count ; i++) {
389
+ LKDBProperty* db_p = [superInfos objectWithIndex: i];
390
+ if (db_p.propertyName && db_p.propertyType && [db_p.propertyName isEqualToString: @" rowid" ]==NO )
378
391
{
379
- pkArray = [NSArray arrayWithObject: pk];
392
+ [pronames addObject: db_p.propertyName];
393
+ [protypes addObject: db_p.propertyType];
380
394
}
381
395
}
382
-
383
- infos = [[LKModelInfos alloc ]initWithKeyMapping:keymapping propertyNames: pronames propertyType: protypes primaryKeys: pkArray];
384
- [oncePropertyDic setObject: infos forKey: NSStringFromClass (self )];
385
396
}
397
+
398
+ infos = [[LKModelInfos alloc ]initWithKeyMapping:keymapping propertyNames: pronames propertyType: protypes primaryKeys: pkArray];
399
+ [oncePropertyDic setObject: infos forKey: NSStringFromClass (self )];
386
400
}
401
+
402
+ [lock unlock ];
387
403
return infos;
388
404
389
405
}
@@ -469,10 +485,6 @@ + (void)getSelfPropertys:(NSMutableArray *)pronames protypes:(NSMutableArray *)p
469
485
}
470
486
}
471
487
free (properties);
472
- if ([self isContainParent ] && [self superclass ] != [NSObject class ])
473
- {
474
- [[self superclass ] getSelfPropertys: pronames protypes: protypes];
475
- }
476
488
}
477
489
478
490
#pragma mark - log all property
0 commit comments