VirtualBox

Changeset 8907 in vbox


Ignore:
Timestamp:
May 19, 2008 9:26:13 AM (17 years ago)
Author:
vboxsync
Message:

FE/Qt4: Make sure that all VBoxVMItems are proberly deleted.

Location:
trunk/src/VBox/Frontends/VirtualBox4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMListView.h

    r8568 r8907  
    100100
    101101    VBoxVMModel(QObject *aParent = 0)
    102         :QAbstractListModel (aParent) { refresh(); }
     102        :QAbstractListModel (aParent) {}
    103103
    104104    void addItem (VBoxVMItem *aItem);
     
    108108    void itemChanged (VBoxVMItem *aItem);
    109109
    110     void refresh();
     110    void clear();
    111111
    112112    VBoxVMItem *itemById (const QUuid &aId) const;
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSelectorWnd.cpp

    r8630 r8907  
    484484    /* VM list view */
    485485    mVMListView = new VBoxVMListView();
    486     mVMModel = new VBoxVMModel();
     486    mVMModel = new VBoxVMModel(mVMListView);
    487487    mVMListView->setModel (mVMModel);
    488488
     
    622622    }
    623623
     624    /* Update the list */
     625    refreshVMList();
    624626    /* Reset to the first item */
    625627    mVMListView->selectItemByRow (0);
     
    716718        vbox.SetExtraData (VBoxDefs::GUI_LastVMSelected, curVMId);
    717719    }
     720    /* Delete the items from our model */
     721    mVMModel->clear();
    718722}
    719723
     
    883887                machine.DeleteSettings();
    884888                /* remove the item shortly: cmachine it refers to is no longer valid! */
    885 #warning "port me: check this"
    886889                int row = mVMModel->rowById (item->id());
    887890                mVMModel->removeItem (item);
     891                delete item;
    888892                mVMListView->ensureSomeRowSelected (row);
    889893            }
     
    10571061void VBoxSelectorWnd::refreshVMList()
    10581062{
    1059     mVMModel->refresh();
     1063    CVirtualBox vbox = vboxGlobal().virtualBox();
     1064    CMachineVector vec = vbox.GetMachines2();
     1065    for (CMachineVector::ConstIterator m = vec.begin();
     1066         m != vec.end(); ++ m)
     1067        mVMModel->addItem (new VBoxVMItem (*m));
     1068    mVMModel->sort();
     1069
    10601070    vmListViewCurrentChanged();
    10611071}
     
    14811491            int row = mVMModel->rowById (item->id());
    14821492            mVMModel->removeItem (item);
     1493            delete item;
    14831494            mVMListView->ensureSomeRowSelected (row);
    14841495        }
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMListView.cpp

    r8568 r8907  
    438438
    439439/**
    440  *  Refreshes the model contents by rereading the list of VM's using the
    441  *  IVirtualBox instance.
     440 *  Clear the item model list. Please note that the items itself are also
     441 *  deleted.
    442442 */
    443 void VBoxVMModel::refresh()
    444 {
    445     CVirtualBox vbox = vboxGlobal().virtualBox();
    446     CMachineVector vec = vbox.GetMachines2();
    447     for (CMachineVector::ConstIterator m = vec.begin();
    448          m != vec.end(); ++ m)
    449         addItem(new VBoxVMItem (*m));
    450 
    451     sort();
     443void VBoxVMModel::clear()
     444{
     445    qDeleteAll (mVMItemList);
    452446}
    453447
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette