* Fixed a memory leak in Deskbar's BarWindow.cpp when adding a deskbar
replicant failed as pointed out by Mark Hellegers. * Clarified ownership of the passed in message in TReplicantTray::AddIcon() as well as BShelf::_AddReplicant(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24621 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -518,7 +518,10 @@ TBarWindow::AddItem(BMessage *message)
|
||||
#endif
|
||||
shelf = B_DESKBAR_TRAY;
|
||||
|
||||
err = fBarView->AddItem(new BMessage(archivedView), shelf, &id);
|
||||
BMessage* archive = new BMessage(archivedView);
|
||||
err = fBarView->AddItem(archive, shelf, &id);
|
||||
if (err < B_OK)
|
||||
delete archive;
|
||||
} else if (message->FindRef("addon", &ref) == B_OK) {
|
||||
//
|
||||
// exposing the name of the view here is not so great
|
||||
|
||||
@@ -1022,15 +1022,15 @@ TReplicantTray::IconCount() const
|
||||
}
|
||||
|
||||
|
||||
/** Message must contain an archivable view
|
||||
* in the Archives folder for later rehydration
|
||||
* returns the current boot id
|
||||
*/
|
||||
|
||||
/*! Message must contain an archivable view for later rehydration.
|
||||
This function takes over ownership of the provided message on success
|
||||
only.
|
||||
Returns the current replicant ID.
|
||||
*/
|
||||
status_t
|
||||
TReplicantTray::AddIcon(BMessage *icon, int32 *id, const entry_ref *addOn)
|
||||
TReplicantTray::AddIcon(BMessage *archive, int32 *id, const entry_ref *addOn)
|
||||
{
|
||||
if (!icon || !id)
|
||||
if (archive == NULL || id == NULL)
|
||||
return B_ERROR;
|
||||
|
||||
// find entry_ref
|
||||
@@ -1041,7 +1041,7 @@ TReplicantTray::AddIcon(BMessage *icon, int32 *id, const entry_ref *addOn)
|
||||
ref = *addOn;
|
||||
} else {
|
||||
const char *signature;
|
||||
status_t status = icon->FindString("add_on", &signature);
|
||||
status_t status = archive->FindString("add_on", &signature);
|
||||
if (status == B_OK) {
|
||||
BRoster roster;
|
||||
status = roster.FindApp(signature, &ref);
|
||||
@@ -1070,15 +1070,15 @@ TReplicantTray::AddIcon(BMessage *icon, int32 *id, const entry_ref *addOn)
|
||||
return status;
|
||||
|
||||
*id = 999;
|
||||
if (icon->what == B_ARCHIVED_OBJECT)
|
||||
icon->what = 0;
|
||||
if (archive->what == B_ARCHIVED_OBJECT)
|
||||
archive->what = 0;
|
||||
|
||||
BRect originalBounds = icon->FindRect("_frame");
|
||||
BRect originalBounds = archive->FindRect("_frame");
|
||||
// this is a work-around for buggy replicants that change their
|
||||
// size in AttachedToWindow() (such as "SVM")
|
||||
|
||||
// !! check for name collisions?
|
||||
status = fShelf->AddReplicant(icon, BPoint(1, 1));
|
||||
status = fShelf->AddReplicant(archive, BPoint(1, 1));
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2007, Haiku.
|
||||
* Copyright 2001-2008, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@@ -1052,7 +1052,7 @@ BShelf::_Archive(BMessage *data) const
|
||||
data->AddInt32("_sg_cnt", fGenCount);
|
||||
|
||||
BMessage archive('ARCV');
|
||||
|
||||
|
||||
for (int32 i = 0; i < fReplicants.CountItems(); i++) {
|
||||
if (((replicant_data *)fReplicants.ItemAt(i))->Archive(&archive) == B_OK)
|
||||
data->AddMessage("replicant", &archive);
|
||||
@@ -1161,6 +1161,7 @@ BShelf::_DeleteReplicant(replicant_data* item)
|
||||
}
|
||||
|
||||
|
||||
//! Takes over ownership of \a data on success only
|
||||
status_t
|
||||
BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
||||
{
|
||||
@@ -1202,7 +1203,7 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Instantiate the object, if this fails we have a zombie
|
||||
image_id image;
|
||||
BArchivable *archivable = _InstantiateObject(data, &image);
|
||||
@@ -1221,7 +1222,6 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
||||
replicant = _GetReplicant(data, view, point, dragger, relation);
|
||||
if (replicant == NULL)
|
||||
return send_reply(data, B_ERROR, uniqueID);
|
||||
|
||||
} else if (fDisplayZombies && fAllowZombies)
|
||||
zombie = _CreateZombie(data, dragger);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user