Changeset 24621

Show
Ignore:
Timestamp:
03/28/08 06:40:55 (2 months ago)
Author:
axeld
Message:
* 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().
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • haiku/trunk/src/apps/deskbar/BarWindow.cpp

    r21960 r24621  
    519519                        shelf = B_DESKBAR_TRAY; 
    520520 
    521                 err = fBarView->AddItem(new BMessage(archivedView), shelf, &id); 
     521                BMessage* archive = new BMessage(archivedView); 
     522                err = fBarView->AddItem(archive, shelf, &id); 
     523                if (err < B_OK) 
     524                        delete archive; 
    522525        } else if (message->FindRef("addon", &ref) == B_OK) { 
    523526                // 
  • haiku/trunk/src/apps/deskbar/StatusView.cpp

    r23500 r24621  
    10231023 
    10241024 
    1025 /**    Message must contain an archivable view 
    1026  *      in the Archives folder for later rehydration 
    1027  *      returns the current boot id 
    1028  */ 
    1029  
     1025/*!    Message must contain an archivable view for later rehydration. 
     1026        This function takes over ownership of the provided message on success 
     1027        only. 
     1028        Returns the current replicant ID. 
     1029*/ 
    10301030status_t 
    1031 TReplicantTray::AddIcon(BMessage *icon, int32 *id, const entry_ref *addOn) 
    1032 { 
    1033         if (!icon || !id
     1031TReplicantTray::AddIcon(BMessage *archive, int32 *id, const entry_ref *addOn) 
     1032{ 
     1033        if (archive == NULL || id == NULL
    10341034                return B_ERROR; 
    10351035 
     
    10421042        } else { 
    10431043                const char *signature; 
    1044                 status_t status = icon->FindString("add_on", &signature); 
     1044                status_t status = archive->FindString("add_on", &signature); 
    10451045                if (status == B_OK) { 
    10461046                        BRoster roster; 
     
    10711071 
    10721072        *id = 999; 
    1073         if (icon->what == B_ARCHIVED_OBJECT) 
    1074                 icon->what = 0; 
    1075  
    1076         BRect originalBounds = icon->FindRect("_frame"); 
     1073        if (archive->what == B_ARCHIVED_OBJECT) 
     1074                archive->what = 0; 
     1075 
     1076        BRect originalBounds = archive->FindRect("_frame"); 
    10771077                // this is a work-around for buggy replicants that change their 
    10781078                // size in AttachedToWindow() (such as "SVM") 
    10791079 
    10801080        // !! check for name collisions? 
    1081         status = fShelf->AddReplicant(icon, BPoint(1, 1)); 
     1081        status = fShelf->AddReplicant(archive, BPoint(1, 1)); 
    10821082        if (status != B_OK) 
    10831083                return status; 
  • haiku/trunk/src/kits/interface/Shelf.cpp

    r24429 r24621  
    11/* 
    2  * Copyright 2001-2007, Haiku. 
     2 * Copyright 2001-2008, Haiku. 
    33 * Distributed under the terms of the MIT License. 
    44 * 
     
    10531053 
    10541054        BMessage archive('ARCV'); 
    1055          
     1055 
    10561056        for (int32 i = 0; i < fReplicants.CountItems(); i++) { 
    10571057                if (((replicant_data *)fReplicants.ItemAt(i))->Archive(&archive) == B_OK) 
     
    11621162 
    11631163 
     1164//! Takes over ownership of \a data on success only 
    11641165status_t 
    11651166BShelf::_AddReplicant(BMessage *data, BPoint *location, uint32 uniqueID) 
     
    12031204                } 
    12041205        } 
    1205          
     1206 
    12061207        // Instantiate the object, if this fails we have a zombie 
    12071208        image_id image; 
     
    12221223                if (replicant == NULL) 
    12231224                        return send_reply(data, B_ERROR, uniqueID); 
    1224  
    12251225        } else if (fDisplayZombies && fAllowZombies) 
    12261226                zombie = _CreateZombie(data, dragger);