Make ownership-taking idempotent during unarchiving.

The previous scheme made it hard to deal with reference-counted objects,
which may be owned by many objects.
This commit is contained in:
Alex Wilson
2012-05-03 08:45:29 +12:00
parent 0a408e4992
commit 4ca2a44779
+2 -8
View File
@@ -299,10 +299,8 @@ BUnarchiveManager::GetArchivableForToken(int32 token,
}
}
if (!info.adopted && owning == BUnarchiver::B_ASSUME_OWNERSHIP)
if (owning == BUnarchiver::B_ASSUME_OWNERSHIP)
info.adopted = true;
else if (info.adopted && owning == BUnarchiver::B_ASSUME_OWNERSHIP)
debugger("Cannot assume ownership of an object that is already owned");
_archivable = info.archivable;
return err;
@@ -399,11 +397,7 @@ BUnarchiveManager::AssumeOwnership(BArchivable* archivable)
|| fObjects[token].archivable != archivable)
return;
if (!fObjects[token].adopted)
fObjects[token].adopted = true;
else {
debugger("Cannot assume ownership of an object that is already owned");
}
fObjects[token].adopted = true;
}