VirtualBox

Changeset 64604 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 8, 2016 6:14:23 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8657: Improve handling of Install GA ISO Image action: GUI should try to mount ISO into free optical drive first (if exist), then to busy drive (otherwise), but never propose force mounting.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDefs.h

    r62493 r64604  
    137137Q_DECLARE_METATYPE(StorageSlot);
    138138
     139/** Common UI: Storage-slot struct extension with exact controller name. */
     140struct ExactStorageSlot : public StorageSlot
     141{
     142    ExactStorageSlot(const QString &strController,
     143                     KStorageBus enmBus, LONG iPort, LONG iDevice)
     144        : StorageSlot(enmBus, iPort, iDevice)
     145        , controller(strController)
     146    {}
     147    QString controller;
     148};
     149
    139150#endif /* !___UIDefs_h___ */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r64102 r64604  
    592592    AssertReturnVoid(!strMediumID.isNull());
    593593
    594     /* Searching for the first suitable controller/slot: */
    595     QString strControllerName;
    596     LONG iCntPort = -1, iCntDevice = -1;
     594    /* Search for a suitable storage slots: */
     595    QList<ExactStorageSlot> freeStorageSlots;
     596    QList<ExactStorageSlot> busyStorageSlots;
    597597    foreach (const CStorageController &controller, machine().GetStorageControllers())
    598598    {
    599599        foreach (const CMediumAttachment &attachment, machine().GetMediumAttachmentsOfController(controller.GetName()))
    600600        {
     601            /* Look for an optical device: */
    601602            if (attachment.GetType() == KDeviceType_DVD)
    602603            {
    603                 strControllerName = controller.GetName();
    604                 iCntPort = attachment.GetPort();
    605                 iCntDevice = attachment.GetDevice();
    606                 break;
     604                /* Append storage slot to corresponding list: */
     605                if (attachment.GetMedium().isNull())
     606                    freeStorageSlots << ExactStorageSlot(controller.GetName(), controller.GetBus(),
     607                                                         attachment.GetPort(), attachment.GetDevice());
     608                else
     609                    busyStorageSlots << ExactStorageSlot(controller.GetName(), controller.GetBus(),
     610                                                         attachment.GetPort(), attachment.GetDevice());
    607611            }
    608612        }
    609         if (!strControllerName.isNull())
    610             break;
    611     }
    612 
    613     /* Make sure suitable controller/slot were found: */
    614     if (strControllerName.isNull())
     613    }
     614
     615    /* Make sure at least one storage slot found: */
     616    QList<ExactStorageSlot> storageSlots = freeStorageSlots + busyStorageSlots;
     617    if (storageSlots.isEmpty())
    615618    {
    616619        msgCenter().cannotMountGuestAdditions(machineName());
     
    627630    }
    628631
    629     /* Mount medium to corresponding controller/slot: */
    630     machine().MountMedium(strControllerName, iCntPort, iCntDevice, medium.medium(), false /* force */);
     632    /* Try to mount medium to first storage slot: */
     633    bool fMounted = false;
     634    while (!storageSlots.isEmpty() && !fMounted)
     635    {
     636        const ExactStorageSlot storageSlot = storageSlots.takeFirst();
     637        machine().MountMedium(storageSlot.controller, storageSlot.port, storageSlot.device, medium.medium(), false /* force */);
     638        if (machine().isOk())
     639            fMounted = true;
     640    }
    631641    if (!machine().isOk())
    632642    {
    633         /* Ask for force mounting: */
    634         if (msgCenter().cannotRemountMedium(machine(), medium, true /* mount? */,
    635                                             true /* retry? */, mainMachineWindow()))
    636         {
    637             /* Force mount medium to the predefined port/device: */
    638             machine().MountMedium(strControllerName, iCntPort, iCntDevice, medium.medium(), true /* force */);
    639             if (!machine().isOk())
    640                 msgCenter().cannotRemountMedium(machine(), medium, true /* mount? */,
    641                                                 false /* retry? */, mainMachineWindow());
    642         }
     643        msgCenter().cannotRemountMedium(machine(), medium, true /* mount? */,
     644                                        false /* retry? */, mainMachineWindow());
    643645    }
    644646}
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