Fixed problem with the AddPathCommand. When ownership of the added paths is

not transfered to the commmand, it needs to add references. If not more of
such problems are lurking, it could already fix ticket #4104. Note that you
can build Icon-O-Matic with referencable tracing turned on (generic/support/
Referenceable.cpp). The backtrace in #4104 would specifically hint at a
problem with assigning paths to shape and then unassigning them. Assigning
them didn't add the references that unassigning the paths removed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32707 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2009-08-26 13:16:40 +00:00
parent 64c68424bd
commit 3ceab7ef3f
1 changed files with 16 additions and 11 deletions

View File

@ -35,14 +35,24 @@ AddPathsCommand::AddPathsCommand(PathContainer* container,
return;
memcpy(fPaths, paths, sizeof(VectorPath*) * fCount);
if (!fOwnsPaths) {
// Add references to paths
for (int32 i = 0; i < fCount; i++) {
if (fPaths[i] != NULL)
fPaths[i]->Acquire();
}
}
}
// destructor
AddPathsCommand::~AddPathsCommand()
{
if (fOwnsPaths && !fPathsAdded && fPaths) {
for (int32 i = 0; i < fCount; i++)
fPaths[i]->Release();
if (!fPathsAdded && fPaths) {
for (int32 i = 0; i < fCount; i++) {
if (fPaths[i] != NULL)
fPaths[i]->Release();
}
}
delete[] fPaths;
}
@ -58,23 +68,18 @@ AddPathsCommand::InitCheck()
status_t
AddPathsCommand::Perform()
{
status_t ret = B_OK;
// add paths to container
int32 index = fIndex;
for (int32 i = 0; i < fCount; i++) {
if (fPaths[i] && !fContainer->AddPath(fPaths[i], index)) {
ret = B_ERROR;
if (fPaths[i] && !fContainer->AddPath(fPaths[i], fIndex + i)) {
// roll back
for (int32 j = i - 1; j >= 0; j--)
fContainer->RemovePath(fPaths[j]);
break;
return B_ERROR;
}
index++;
}
fPathsAdded = true;
return ret;
return B_OK;
}
// Undo