* 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
|
#endif
|
||||||
shelf = B_DESKBAR_TRAY;
|
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) {
|
} else if (message->FindRef("addon", &ref) == B_OK) {
|
||||||
//
|
//
|
||||||
// exposing the name of the view here is not so great
|
// exposing the name of the view here is not so great
|
||||||
|
|||||||
@@ -1022,15 +1022,15 @@ TReplicantTray::IconCount() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Message must contain an archivable view
|
/*! Message must contain an archivable view for later rehydration.
|
||||||
* in the Archives folder for later rehydration
|
This function takes over ownership of the provided message on success
|
||||||
* returns the current boot id
|
only.
|
||||||
*/
|
Returns the current replicant ID.
|
||||||
|
*/
|
||||||
status_t
|
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;
|
return B_ERROR;
|
||||||
|
|
||||||
// find entry_ref
|
// find entry_ref
|
||||||
@@ -1041,7 +1041,7 @@ TReplicantTray::AddIcon(BMessage *icon, int32 *id, const entry_ref *addOn)
|
|||||||
ref = *addOn;
|
ref = *addOn;
|
||||||
} else {
|
} else {
|
||||||
const char *signature;
|
const char *signature;
|
||||||
status_t status = icon->FindString("add_on", &signature);
|
status_t status = archive->FindString("add_on", &signature);
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
BRoster roster;
|
BRoster roster;
|
||||||
status = roster.FindApp(signature, &ref);
|
status = roster.FindApp(signature, &ref);
|
||||||
@@ -1070,15 +1070,15 @@ TReplicantTray::AddIcon(BMessage *icon, int32 *id, const entry_ref *addOn)
|
|||||||
return status;
|
return status;
|
||||||
|
|
||||||
*id = 999;
|
*id = 999;
|
||||||
if (icon->what == B_ARCHIVED_OBJECT)
|
if (archive->what == B_ARCHIVED_OBJECT)
|
||||||
icon->what = 0;
|
archive->what = 0;
|
||||||
|
|
||||||
BRect originalBounds = icon->FindRect("_frame");
|
BRect originalBounds = archive->FindRect("_frame");
|
||||||
// this is a work-around for buggy replicants that change their
|
// this is a work-around for buggy replicants that change their
|
||||||
// size in AttachedToWindow() (such as "SVM")
|
// size in AttachedToWindow() (such as "SVM")
|
||||||
|
|
||||||
// !! check for name collisions?
|
// !! check for name collisions?
|
||||||
status = fShelf->AddReplicant(icon, BPoint(1, 1));
|
status = fShelf->AddReplicant(archive, BPoint(1, 1));
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2007, Haiku.
|
* Copyright 2001-2008, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -1161,6 +1161,7 @@ BShelf::_DeleteReplicant(replicant_data* item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! Takes over ownership of \a data on success only
|
||||||
status_t
|
status_t
|
||||||
BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
||||||
{
|
{
|
||||||
@@ -1221,7 +1222,6 @@ BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID)
|
|||||||
replicant = _GetReplicant(data, view, point, dragger, relation);
|
replicant = _GetReplicant(data, view, point, dragger, relation);
|
||||||
if (replicant == NULL)
|
if (replicant == NULL)
|
||||||
return send_reply(data, B_ERROR, uniqueID);
|
return send_reply(data, B_ERROR, uniqueID);
|
||||||
|
|
||||||
} else if (fDisplayZombies && fAllowZombies)
|
} else if (fDisplayZombies && fAllowZombies)
|
||||||
zombie = _CreateZombie(data, dragger);
|
zombie = _CreateZombie(data, dragger);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user