Permalink
Browse files

Don't use hasChanges outside of a performBlock on non-confinement typ…

…e contexts
  • Loading branch information...
1 parent 6863ec6 commit e08d5266c0582643b9bb3f4b45ad26514d963638 @tonyarnold tonyarnold committed Jun 13, 2014
@@ -36,7 +36,20 @@ - (void) MR_saveToPersistentStoreAndWait;
- (void) MR_saveWithOptions:(MRSaveOptions)mask completion:(MRSaveCompletionHandler)completion;
{
- if (![self hasChanges])
+ __block BOOL hasChanges = NO;
+
+ if ([self concurrencyType] == NSConfinementConcurrencyType)
+ {
+ hasChanges = [self hasChanges];
+ }
+ else
+ {
+ [self performBlockAndWait:^{
+ hasChanges = [self hasChanges];
+ }];
+ }
+
+ if (!hasChanges)
{
MRLogVerbose(@"NO CHANGES IN ** %@ ** CONTEXT - NOT SAVING", [self MR_workingName]);

1 comment on commit e08d526

idStar commented on e08d526 Jun 21, 2014

@tonyarnold Much needed fix. Thank you.

I can now delete Managed Objects in an MOC and have the save actually go through when that was the only change in the MOC. Prior, in version 2.2, such a save operation was being skipped over because 'hasChanges' was returning NO. Using this development version change you've just made, I can confirm that the correct behavior is now exhibited.

Please sign in to comment.