VirtualBox

Changeset 83683 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 13, 2020 6:34:08 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137178
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: A bit of cleanup for local machine removal procedure.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r83682 r83683  
    4646#include "UIVirtualBoxManagerWidget.h"
    4747#include "UIVirtualMachineItemCloud.h"
     48#include "UIVirtualMachineItemLocal.h"
    4849#include "UIWizardAddCloudVM.h"
    4950#include "UIWizardNewVM.h"
     
    11231124    QMap<QUuid, bool> verdicts;
    11241125    QList<UIChooserItem*> itemsToRemove;
    1125     QList<QUuid> machinesToUnregister;
     1126    QList<CMachine> localMachinesToUnregister;
    11261127
    11271128    /* For each selected machine-item: */
     
    11291130    {
    11301131        /* Get machine-item id: */
    1131         QUuid uId = pItem->toMachineItem()->id();
     1132        const QUuid uId = pItem->toMachineItem()->id();
    11321133
    11331134        /* We already decided for that machine? */
     
    11351136        {
    11361137            /* To remove similar machine items? */
    1137             if (!verdicts[uId])
     1138            if (!verdicts.value(uId))
    11381139                itemsToRemove << pItem;
    11391140            continue;
     
    11531154         * we will propose ro unregister machine fully else
    11541155         * we will just propose to remove selected-items: */
    1155         bool fVerdict = iSelectedCopyCount == iExistingCopyCount;
     1156        const bool fVerdict = iSelectedCopyCount == iExistingCopyCount;
    11561157        verdicts.insert(uId, fVerdict);
    11571158        if (fVerdict)
    1158             machinesToUnregister.append(uId);
     1159            localMachinesToUnregister.append(pItem->node()->toMachineNode()->cache()->toLocal()->machine());
    11591160        else
    11601161            itemsToRemove << pItem;
     
    11641165    if (!itemsToRemove.isEmpty())
    11651166        removeItems(itemsToRemove);
    1166     /* If we have something to unregister: */
    1167     if (!machinesToUnregister.isEmpty())
    1168         unregisterMachines(machinesToUnregister);
     1167    /* If we have something local to unregister: */
     1168    if (!localMachinesToUnregister.isEmpty())
     1169        unregisterMachines(localMachinesToUnregister);
    11691170}
    11701171
     
    16331634}
    16341635
    1635 void UIChooserModel::unregisterMachines(const QList<QUuid> &ids)
    1636 {
    1637     /* Populate machine list: */
    1638     QList<CMachine> machines;
    1639     CVirtualBox vbox = uiCommon().virtualBox();
    1640     foreach (const QUuid &uId, ids)
    1641     {
    1642         CMachine machine = vbox.FindMachine(uId.toString());
    1643         if (!machine.isNull())
    1644             machines << machine;
    1645     }
    1646 
     1636void UIChooserModel::unregisterMachines(const QList<CMachine> &machines)
     1637{
    16471638    /* Confirm machine removal: */
    16481639    int iResultCode = msgCenter().confirmMachineRemoval(machines);
     
    16531644    setSelectedItem(findClosestUnselectedItem());
    16541645
    1655     /* For every selected-item: */
    1656     for (int iMachineIndex = 0; iMachineIndex < machines.size(); ++iMachineIndex)
    1657     {
    1658         /* Get iterated machine: */
    1659         CMachine &machine = machines[iMachineIndex];
     1646    /* For every selected machine: */
     1647    foreach (CMachine comMachine, machines)
     1648    {
    16601649        if (iResultCode == AlertButton_Choice1)
    16611650        {
    16621651            /* Unregister machine first: */
    1663             CMediumVector media = machine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly);
    1664             if (!machine.isOk())
     1652            CMediumVector comMedia = comMachine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly);
     1653            if (!comMachine.isOk())
    16651654            {
    1666                 msgCenter().cannotRemoveMachine(machine);
     1655                msgCenter().cannotRemoveMachine(comMachine);
    16671656                continue;
    16681657            }
    16691658            /* Prepare cleanup progress: */
    1670             CProgress progress = machine.DeleteConfig(media);
    1671             if (!machine.isOk())
     1659            CProgress comProgress = comMachine.DeleteConfig(comMedia);
     1660            if (!comMachine.isOk())
    16721661            {
    1673                 msgCenter().cannotRemoveMachine(machine);
     1662                msgCenter().cannotRemoveMachine(comMachine);
    16741663                continue;
    16751664            }
    16761665            /* And show cleanup progress finally: */
    1677             msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_delete_90px.png");
    1678             if (!progress.isOk() || progress.GetResultCode() != 0)
     1666            msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(), ":/progress_delete_90px.png");
     1667            if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    16791668            {
    1680                 msgCenter().cannotRemoveMachine(machine, progress);
     1669                msgCenter().cannotRemoveMachine(comMachine, comProgress);
    16811670                continue;
    16821671            }
     
    16851674        {
    16861675            /* Unregister machine first: */
    1687             CMediumVector media = machine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly);
    1688             if (!machine.isOk())
     1676            CMediumVector comMedia = comMachine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly);
     1677            if (!comMachine.isOk())
    16891678            {
    1690                 msgCenter().cannotRemoveMachine(machine);
     1679                msgCenter().cannotRemoveMachine(comMachine);
    16911680                continue;
    16921681            }
    16931682            /* Finally close all media, deliberately ignoring errors: */
    1694             foreach (CMedium medium, media)
     1683            foreach (CMedium comMedium, comMedia)
    16951684            {
    1696                 if (!medium.isNull())
    1697                     medium.Close();
     1685                if (!comMedium.isNull())
     1686                    comMedium.Close();
    16981687            }
    16991688        }
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h

    r83674 r83683  
    2828#include "UIChooserAbstractModel.h"
    2929#include "UIExtraDataDefs.h"
     30
     31/* COM includes: */
     32#include "COMEnums.h"
     33#include "CMachine.h"
    3034
    3135/* Forward declaration: */
     
    359363        /** Removes machine @a items. */
    360364        void removeItems(const QList<UIChooserItem*> &items);
    361         /** Unregisters virtual machines using list of @a ids. */
    362         void unregisterMachines(const QList<QUuid> &ids);
     365        /** Unregisters a list of virtual @a machines. */
     366        void unregisterMachines(const QList<CMachine> &machines);
    363367
    364368        /** Processes drag move @a pEvent. */
Note: See TracChangeset for help on using the changeset viewer.

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