Index: sync/syncable/syncable_util.cc |
diff --git a/sync/syncable/syncable_util.cc b/sync/syncable/syncable_util.cc |
index d92aa47ed46d1e633da74123d3191010c46c27de..a8aca33747e4431bb5553363ac74c6a705d59197 100644 |
--- a/sync/syncable/syncable_util.cc |
+++ b/sync/syncable/syncable_util.cc |
@@ -28,8 +28,11 @@ int GetUnsyncedEntries(BaseTransaction* trans, |
bool IsLegalNewParent(BaseTransaction* trans, const Id& entry_id, |
const Id& new_parent_id) { |
+ DCHECK(!entry_id.IsNull()); |
if (entry_id.IsRoot()) |
return false; |
+ if (new_parent_id.IsNull()) |
+ return true; |
Nicolas Zea
2015/01/26 23:21:53
Should this be false here for bookmarks?
stanisc
2015/01/28 07:30:06
Yes, I agree. I'll see if this check could be done
stanisc
2015/01/29 00:27:37
Done.
|
// we have to ensure that the entry is not an ancestor of the new parent. |
Id ancestor_id = new_parent_id; |
while (!ancestor_id.IsRoot()) { |
@@ -66,11 +69,14 @@ void ChangeEntryIDAndUpdateChildren( |
while (i != children.end()) { |
ModelNeutralMutableEntry child_entry(trans, GET_BY_HANDLE, *i++); |
CHECK(child_entry.good()); |
- // Use the unchecked setter here to avoid touching the child's |
- // UNIQUE_POSITION field. In this case, UNIQUE_POSITION among the |
- // children will be valid after the loop, since we update all the children |
- // at once. |
- child_entry.PutParentIdPropertyOnly(new_id); |
+ // Change the parent ID of the entry unless it was unset (implicit) |
+ if (!child_entry.GetParentId().IsNull()) { |
+ // Use the unchecked setter here to avoid touching the child's |
+ // UNIQUE_POSITION field. In this case, UNIQUE_POSITION among the |
+ // children will be valid after the loop, since we update all the |
+ // children at once. |
+ child_entry.PutParentIdPropertyOnly(new_id); |
+ } |
} |
} |
} |