Skip to content

Commit 38be076

Browse files
Merge pull request #306 from ParsePlatform/richardross.collectdirtychildren.deadlock
Fixed deadlock in -collectDirtyChildren:
2 parents fc2d6c8 + da2df65 commit 38be076

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Parse/PFObject.m

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ + (void)collectDirtyChildren:(id)node
263263

264264
} else if ([node isKindOfClass:[PFObject class]]) {
265265
PFObject *object = (PFObject *)node;
266+
NSDictionary *toSearch = nil;
266267

267268
@synchronized ([object lock]) {
268269
// Check for cycles of new objects. Any such cycle means it will be
@@ -288,18 +289,19 @@ + (void)collectDirtyChildren:(id)node
288289
// Recurse into this object's children looking for dirty children.
289290
// We only need to look at the child object's current estimated data,
290291
// because that's the only data that might need to be saved now.
291-
[self collectDirtyChildren:object->_estimatedData.dictionaryRepresentation
292-
children:dirtyChildren
293-
files:dirtyFiles
294-
seen:seen
295-
seenNew:seenNew
296-
currentUser:currentUser];
297-
298-
if ([object isDirty:NO]) {
299-
[dirtyChildren addObject:object];
300-
}
292+
toSearch = [object->_estimatedData.dictionaryRepresentation copy];
301293
}
302294

295+
[self collectDirtyChildren:toSearch
296+
children:dirtyChildren
297+
files:dirtyFiles
298+
seen:seen
299+
seenNew:seenNew
300+
currentUser:currentUser];
301+
302+
if ([object isDirty:NO]) {
303+
[dirtyChildren addObject:object];
304+
}
303305
} else if ([node isKindOfClass:[PFFile class]]) {
304306
PFFile *file = (PFFile *)node;
305307
if (!file.url) {

0 commit comments

Comments
 (0)