VirtualBox

Changeset 78539 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 16, 2019 9:42:39 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
130584
Message:

FE/Qt: bugref:6247: VM Settings / Storage page: Make sure there is no optical devices left for controller when bus type is changed to NVMe.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r78396 r78539  
    11151115                          QString() /* cancel button text */,
    11161116                          false /* ok button by default? */);
     1117}
     1118
     1119bool UIMessageCenter::confirmStorageBusChangeWithOpticalRemoval(QWidget *pParent /* = 0 */) const
     1120{
     1121    return questionBinary(pParent, MessageType_Question,
     1122                          tr("<p>This controller has optical devices attached.  You have requested storage bus "
     1123                             "change to type which doesn't support optical devices.</p><p>If you proceed optical "
     1124                             "devices will be removed.</p>"));
    11171125}
    11181126
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r78396 r78539  
    319319    bool confirmSettingsReloading(QWidget *pParent = 0) const;
    320320    int confirmRemovingOfLastDVDDevice(QWidget *pParent = 0) const;
     321    bool confirmStorageBusChangeWithOpticalRemoval(QWidget *pParent = 0) const;
    321322    void cannotAttachDevice(const CMachine &machine, UIMediumDeviceType type, const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent = 0);
    322323    bool warnAboutIncorrectPort(QWidget *pParent = 0) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r78538 r78539  
    805805}
    806806
     807QList<QUuid> ControllerItem::attachmentIDs(KDeviceType enmType /* = KDeviceType_Null */) const
     808{
     809    QList<QUuid> ids;
     810    foreach (AbstractItem *pItem, mAttachments)
     811    {
     812        AttachmentItem *pItemAttachment = static_cast<AttachmentItem*>(pItem);
     813        if (   enmType == KDeviceType_Null
     814            || pItemAttachment->attDeviceType() == enmType)
     815            ids << pItem->id();
     816    }
     817    return ids;
     818}
     819
    807820AbstractItem::ItemType ControllerItem::rtti() const
    808821{
     
    16871700                    ControllerItem *pItemController = static_cast<ControllerItem*>(pItem);
    16881701                    const KStorageBus enmNewCtrBusType = aValue.value<KStorageBus>();
     1702
     1703                    /* PCIe devices allows for hard-drives attachments only,
     1704                     * no optical devices. So, lets make sure that rule is fulfilled. */
     1705                    if (enmNewCtrBusType == KStorageBus_PCIe)
     1706                    {
     1707                        const QList<QUuid> opticalIds = pItemController->attachmentIDs(KDeviceType_DVD);
     1708                        if (!opticalIds.isEmpty())
     1709                        {
     1710                            if (!msgCenter().confirmStorageBusChangeWithOpticalRemoval())
     1711                                return false;
     1712                            foreach (const QUuid &uId, opticalIds)
     1713                                delAttachment(pItemController->id(), uId);
     1714                        }
     1715                    }
     1716
    16891717                    pItemController->setCtrBusType(enmNewCtrBusType);
    16901718                    emit dataChanged(aIndex, aIndex);
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h

    r78538 r78539  
    278278    SlotsList ctrUsedSlots() const;
    279279    DeviceTypeList ctrDeviceTypeList() const;
     280
     281    QList<QUuid> attachmentIDs(KDeviceType enmType = KDeviceType_Null) const;
    280282
    281283    void setAttachments(const QList<AbstractItem*> &attachments) { mAttachments = attachments; }
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