VirtualBox

Changeset 67601 in vbox


Ignore:
Timestamp:
Jun 26, 2017 11:54:00 AM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: Do not forget to save machine settings manually after inserting DVD device through First Run wizard; it's not that necessary right now since being done automatically, but still a correct thing to do.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRun.cpp

    r63567 r67601  
    5050bool UIWizardFirstRun::insertMedium()
    5151{
    52     /* Get 'vbox' global object: */
    53     CVirtualBox vbox = vboxGlobal().virtualBox();
    54     /* Determine machine 'OS type': */
    55     const CGuestOSType &osType = vbox.GetGuestOSType(m_machine.GetOSTypeId());
    56     /* Determine recommended controller's 'bus' & 'type': */
    57     KStorageBus dvdCtrBus = osType.GetRecommendedDVDStorageBus();
    58     KStorageControllerType dvdCtrType = osType.GetRecommendedDVDStorageController();
    59     /* Declare null 'dvd' attachment: */
    60     CMediumAttachment cda;
    61     /* Enumerate attachments vector: */
    62     const CMediumAttachmentVector &attachments = m_machine.GetMediumAttachments();
    63     for (int i = 0; i < attachments.size(); ++i)
     52    /* Prepare result: */
     53    bool fSuccess = true;
     54
     55    /* Get global VBox object: */
     56    CVirtualBox comVbox = vboxGlobal().virtualBox();
     57    /* Get machine OS type: */
     58    const CGuestOSType &comOsType = comVbox.GetGuestOSType(m_machine.GetOSTypeId());
     59    /* Get recommended controller bus & type: */
     60    const KStorageBus enmRecommendedDvdBus = comOsType.GetRecommendedDVDStorageBus();
     61    const KStorageControllerType enmRecommendedDvdType = comOsType.GetRecommendedDVDStorageController();
     62
     63    /* Prepare null medium attachment: */
     64    CMediumAttachment comAttachment;
     65    /* Search for an attachment of required bus & type: */
     66    foreach (const CMediumAttachment &comCurrentAttachment, m_machine.GetMediumAttachments())
    6467    {
    65         /* Get current attachment: */
    66         const CMediumAttachment &attachment = attachments[i];
    67         /* Determine attachment's controller: */
    68         const CStorageController &controller = m_machine.GetStorageControllerByName(attachment.GetController());
    69         /* If controller's 'bus' & 'type' are recommended and attachment's 'type' is 'dvd': */
    70         if (controller.GetBus() == dvdCtrBus &&
    71             controller.GetControllerType() == dvdCtrType &&
    72             attachment.GetType() == KDeviceType_DVD)
     68        /* Determine current attachment's controller: */
     69        const CStorageController &comCurrentController = m_machine.GetStorageControllerByName(comCurrentAttachment.GetController());
     70        /* If current controller bus & type are recommended and attachment type is 'dvd': */
     71        if (   comCurrentController.GetBus() == enmRecommendedDvdBus
     72            && comCurrentController.GetControllerType() == enmRecommendedDvdType
     73            && comCurrentAttachment.GetType() == KDeviceType_DVD)
    7374        {
    7475            /* Remember attachment: */
    75             cda = attachment;
     76            comAttachment = comCurrentAttachment;
    7677            break;
    7778        }
    7879    }
    79     AssertMsg(!cda.isNull(), ("Storage Controller is NOT properly configured!\n"));
     80    AssertMsgReturn(!comAttachment.isNull(), ("Storage Controller is NOT properly configured!\n"), false);
     81
     82    // In place where the UIWizardFirstRun is currently being opened
     83    // we doesn't have to open direct or shared session because it's
     84    // already opened for the VM which being cached in this wizard.
     85
    8086    /* Get chosen 'dvd' medium to mount: */
    81     QString mediumId = field("id").toString();
    82     UIMedium vmedium = vboxGlobal().medium(mediumId);
    83     CMedium medium = vmedium.medium(); /// @todo r=dj can this be cached somewhere?
     87    const QString strMediumId = field("id").toString();
     88    const UIMedium guiMedium = vboxGlobal().medium(strMediumId);
     89    const CMedium comMedium = guiMedium.medium();
     90
    8491    /* Mount medium to the predefined port/device: */
    85     m_machine.MountMedium(cda.GetController(), cda.GetPort(), cda.GetDevice(), medium, false /* force */);
    86     if (m_machine.isOk())
    87         return true;
     92    m_machine.MountMedium(comAttachment.GetController(), comAttachment.GetPort(), comAttachment.GetDevice(), comMedium, false /* force */);
     93    fSuccess = m_machine.isOk();
     94
     95    /* Show error message if necessary: */
     96    if (!fSuccess)
     97        msgCenter().cannotRemountMedium(m_machine, guiMedium, true /* mount? */, false /* retry? */, this);
    8898    else
    8999    {
    90         msgCenter().cannotRemountMedium(m_machine, vmedium, true /* mount? */, false /* retry? */, this);
    91         return false;
     100        /* Save machine settings: */
     101        m_machine.SaveSettings();
     102        fSuccess = m_machine.isOk();
     103
     104        /* Show error message if necessary: */
     105        if (!fSuccess)
     106            msgCenter().cannotSaveMachineSettings(m_machine, this);
    92107    }
     108
     109    /* Return result: */
     110    return fSuccess;
    93111}
    94112
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