Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Warnings fix #131

Closed
wants to merge 11 commits into from

2 participants

@dav

I run pretty strict warnings so fixed these to get clean. The second one should be fine, not as certain about the first one (the block local var shadowing) so you might want to take a closer look at that to be sure.

NSManagedObject+MagicalDataImport.m:242:81: warning: declaration shadows a local variable [-Wshadow,3]
NSObject+MagicalDataImport.m: warning: comparison of integers of different signs: 'int' and 'const NSUInteger' (aka 'const unsigned int') [-Wsign-compare,3]

dav added some commits
@dav dav DIY: update to fix compiler warnings
NSManagedObject+MagicalDataImport.m:242:81: warning: declaration shadows a local variable [-Wshadow,3]
NSObject+MagicalDataImport.m: warning: comparison of integers of different signs: 'int' and 'const NSUInteger' (aka 'const unsigned int') [-Wsign-compare,3]
ff898d3
@dav dav DIY: Replaced performSelectorOnMainThread with my usual method, as I …
…was getting deadlocks I couldn't track down and just wanted to make sure this wasn't part of the problem. Voodoo, perhaps.

See also http://stackoverflow.com/a/5226271/426608
b200697
@dav dav DIY: force using pre-iOS5 style thread handling a6e6d7f
@dav dav DIY: adding a bit of debugging info for now c76a05f
@dav dav DIY: fix a couple of CLANG warnings ea970a2
@dav dav DIY: Adding orginal lines commented out in case I rollback manually l…
…ater
bcba846
@dav dav DIY: Was crashing in XCode4.2 and 5.0 simulator. This nil check seems…
… to fix it.

Wish I had time to dig deeper.
3069938
@dav dav Merge remote-tracking branch 'reference/master'
Conflicts:
	Source/Categories/NSManagedObject+MagicalDataImport.m
991c82b
@dav dav DIT: Don't use Three20 stuff in a different external project. 6ce1a2c
@dav dav DIY: added nil check
Refs: I think there was a crash prompting this fix, but made the change weeks ago and forgot to check in so not sure. Doh.
1d1af94
@dav dav Merge branch 'master' of github.com:dav/MagicalRecord
Conflicts:
	Source/Categories/NSPersistentStore+MagicalRecord.m
4d3d1bd
@blackgold9 blackgold9 was assigned
@blackgold9
Collaborator

These changes are very out of date now, so I'm closing this, and will take a warnings pass through the code.

@blackgold9 blackgold9 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 16, 2012
  1. @dav

    DIY: update to fix compiler warnings

    dav authored
    NSManagedObject+MagicalDataImport.m:242:81: warning: declaration shadows a local variable [-Wshadow,3]
    NSObject+MagicalDataImport.m: warning: comparison of integers of different signs: 'int' and 'const NSUInteger' (aka 'const unsigned int') [-Wsign-compare,3]
  2. @dav

    DIY: Replaced performSelectorOnMainThread with my usual method, as I …

    dav authored
    …was getting deadlocks I couldn't track down and just wanted to make sure this wasn't part of the problem. Voodoo, perhaps.
    
    See also http://stackoverflow.com/a/5226271/426608
  3. @dav
  4. @dav
  5. @dav
  6. @dav
Commits on Mar 8, 2012
  1. @dav

    DIY: Was crashing in XCode4.2 and 5.0 simulator. This nil check seems…

    dav authored
    … to fix it.
    
    Wish I had time to dig deeper.
  2. @dav

    Merge remote-tracking branch 'reference/master'

    dav authored
    Conflicts:
    	Source/Categories/NSManagedObject+MagicalDataImport.m
  3. @dav
Commits on Mar 19, 2012
  1. @dav

    DIY: added nil check

    dav authored
    Refs: I think there was a crash prompting this fix, but made the change weeks ago and forgot to check in so not sure. Doh.
  2. @dav

    Merge branch 'master' of github.com:dav/MagicalRecord

    dav authored
    Conflicts:
    	Source/Categories/NSPersistentStore+MagicalRecord.m
This page is out of date. Refresh to see the latest.
View
2  Source/Categories/DataImport/NSObject+MagicalDataImport.m
@@ -33,7 +33,7 @@ - (NSString *) MR_lookupKeyForAttribute:(NSAttributeDescription *)attributeInfo;
id value = [self valueForKeyPath:lookupKey];
- for (int i = 1; i < kMagicalRecordImportMaximumAttributeFailoverDepth && value == nil; i++)
+ for (NSUInteger i = 1; i < kMagicalRecordImportMaximumAttributeFailoverDepth && value == nil; i++)
{
attributeName = [NSString stringWithFormat:@"%@.%d", kMagicalRecordImportAttributeKeyMapKey, i];
lookupKey = [[attributeInfo userInfo] valueForKey:attributeName];
View
12 Source/Categories/NSManagedObject+MagicalDataImport.m
@@ -202,7 +202,7 @@ - (void) MR_importValuesForKeysWithDictionary:(id)objectData
NSDictionary *relationships = [[self entity] relationshipsByName];
[self MR_setRelationships:relationships
forKeysWithDictionary:objectData
- withBlock:^(NSRelationshipDescription *relationshipInfo, id objectData){
+ withBlock:^(NSRelationshipDescription *relationshipInfo, id blockObjectData){
NSManagedObject *relatedObject = nil;
if ([objectData isKindOfClass:[NSDictionary class]])
@@ -222,9 +222,9 @@ - (void) MR_importValuesForKeysWithDictionary:(id)objectData
}
else
{
- relatedObject = [self MR_findObjectForRelationship:relationshipInfo withData:objectData];
+ relatedObject = [self MR_findObjectForRelationship:relationshipInfo withData:blockObjectData];
}
- [relatedObject MR_importValuesForKeysWithDictionary:objectData];
+ [relatedObject MR_importValuesForKeysWithDictionary:blockObjectData];
[self MR_addObject:relatedObject forRelationship:relationshipInfo];
}];
@@ -250,13 +250,13 @@ - (void) MR_updateValuesForKeysWithDictionary:(id)objectData
NSDictionary *relationships = [[self entity] relationshipsByName];
[self MR_setRelationships:relationships
forKeysWithDictionary:objectData
- withBlock:^(NSRelationshipDescription *relationshipInfo, id objectData) {
+ withBlock:^(NSRelationshipDescription *relationshipInfo, id blockObjectData) {
NSManagedObject *relatedObject = [self MR_findObjectForRelationship:relationshipInfo
- withData:objectData];
+ withData:blockObjectData];
if (relatedObject == nil)
{
- relatedObject = [[relationshipInfo destinationEntity] MR_createInstanceFromDictionary:objectData inContext:[self managedObjectContext]];
+ relatedObject = [[relationshipInfo destinationEntity] MR_createInstanceFromDictionary:blockObjectData inContext:[self managedObjectContext]];
}
else
{
View
29 Source/Categories/NSManagedObjectContext+MagicalRecord.m
@@ -17,6 +17,7 @@ @interface NSManagedObjectContext (MagicalRecordPrivate)
- (void) MR_mergeChangesFromNotification:(NSNotification *)notification;
- (void) MR_mergeChangesOnMainThread:(NSNotification *)notification;
+- (void) runOnMainQueueWithoutDeadlocking:(void (^)(void))block;
@end
@@ -141,7 +142,10 @@ - (void) MR_mergeChangesOnMainThread:(NSNotification *)notification;
}
else
{
- [self performSelectorOnMainThread:@selector(MR_mergeChangesFromNotification:) withObject:notification waitUntilDone:YES];
+ // [self performSelectorOnMainThread:@selector(MR_mergeChangesFromNotification:) withObject:notification waitUntilDone:YES];
+ [self runOnMainQueueWithoutDeadlocking:^{
+ [self MR_mergeChangesFromNotification:notification];
+ }];
}
}
@@ -219,7 +223,10 @@ - (BOOL) MR_saveOnMainThread;
{
@synchronized(self)
{
- [self performSelectorOnMainThread:@selector(MR_saveWrapper) withObject:nil waitUntilDone:YES];
+ // [self performSelectorOnMainThread:@selector(MR_saveWrapper) withObject:nil waitUntilDone:YES];
+ [self runOnMainQueueWithoutDeadlocking:^{
+ [self MR_saveWrapper];
+ }];
}
return YES;
@@ -292,6 +299,7 @@ + (NSManagedObjectContext *) MR_contextWithStoreCoordinator:(NSPersistentStoreCo
MRLog(@"Creating context in Thread Isolation Mode");
context = [[NSManagedObjectContext alloc] init];
[context setPersistentStoreCoordinator:coordinator];
+ MR_AUTORELEASE(context);
)
PRIVATE_QUEUES_ENABLED(
MRLog(@"Creating context in Context Private Queue Mode");
@@ -299,9 +307,8 @@ + (NSManagedObjectContext *) MR_contextWithStoreCoordinator:(NSPersistentStoreCo
[context performBlockAndWait:^{
[context setPersistentStoreCoordinator:coordinator];
}];
+ MR_AUTORELEASE(context);
)
-
- MR_AUTORELEASE(context);
}
return context;
}
@@ -332,7 +339,7 @@ + (NSManagedObjectContext *) MR_contextThatNotifiesDefaultContextOnMainThread;
PRIVATE_QUEUES_ENABLED
(
MRLog(@"Creating Context - Using Private queue mode");
- context = [[self alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
+ context = [[[self alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType] autorelease];
if (context != [self MR_defaultContext])
{
[context setParentContext:[NSManagedObjectContext MR_defaultContext]];
@@ -342,4 +349,16 @@ + (NSManagedObjectContext *) MR_contextThatNotifiesDefaultContextOnMainThread;
return context;
}
+#pragma mark -
+
+- (void) runOnMainQueueWithoutDeadlocking:(void (^)(void))block {
+ if ([NSThread isMainThread]) {
+ MXLog(@"Running MR block from main thread");
+ block();
+ } else {
+ MXLog(@"Running MR block through dispatch_sync to main queue");
+ dispatch_sync(dispatch_get_main_queue(), block);
+ }
+}
+
@end
View
2  Source/Categories/NSPersistentStore+MagicalRecord.m
@@ -66,7 +66,7 @@ + (NSURL *) MR_cloudURLForUbiqutiousContainer:(NSString *)bucketName;
{
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSURL *cloudURL = nil;
- if ([fileManager respondsToSelector:@selector(URLForUbiquityContainerIdentifier:)])
+ if (([bucketName isKindOfClass:[NSString class]] && [bucketName length] > 0) && [fileManager respondsToSelector:@selector(URLForUbiquityContainerIdentifier:)])
{
cloudURL = [fileManager URLForUbiquityContainerIdentifier:bucketName];
}
View
5 Source/CoreData+MagicalRecord.h
@@ -29,7 +29,10 @@
#endif
#ifndef kCFCoreFoundationVersionNumber_iPhoneOS_5_0
-#define kCFCoreFoundationVersionNumber_iPhoneOS_5_0 674.0
+// Replacing this because encoutnering deadlocks. See https://github.com/magicalpanda/MagicalRecord/pull/114 for similar discussion
+// TODO figure out how to get iOS5 supported properly
+//#define kCFCoreFoundationVersionNumber_iPhoneOS_5_0 674.0
+#define kCFCoreFoundationVersionNumber_iPhoneOS_5_0 9999.0
#endif
#ifndef kCFCoreFoundationVersionNumber_10_7
View
1  Source/MRCoreDataAction.m
@@ -58,6 +58,7 @@ + (void) saveDataWithBlock:(void (^)(NSManagedObjectContext *localContext))block
localContext = [NSManagedObjectContext MR_contextThatNotifiesDefaultContextOnMainThread];
[localContext MR_observeiCloudChangesInCoordinator:defaultCoordinator];
#endif
+ NSLog(@"Created localContext: %@; mainContext=%@", localContext, mainContext);
[mainContext setMergePolicy:NSMergeByPropertyStoreTrumpMergePolicy];
[localContext setMergePolicy:NSOverwriteMergePolicy];
}
Something went wrong with that request. Please try again.