VirtualBox

Ignore:
Timestamp:
Jun 1, 2010 12:07:18 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt: 4998: First Run Wizard regression should be fixed.

File:
1 edited

Legend:

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

    r29730 r29942  
    6262}
    6363
    64 bool UIFirstRunWzd::isDefaultHardDiskAttached(const CMachine &machine)
    65 {
    66     LONG iPort = 0;
    67     LONG iDevice = 0;
     64bool UIFirstRunWzd::isBootHardDiskAttached(const CMachine &machine)
     65{
     66    /* Result is 'false' initially: */
     67    bool fIsBootHardDiskAttached = false;
     68    /* Get 'vbox' global object: */
    6869    CVirtualBox vbox = vboxGlobal().virtualBox();
    69     CGuestOSType type = vbox.GetGuestOSType(machine.GetOSTypeId());
    70     KStorageBus ctrDvdBus = type.GetRecommendedDvdStorageBus();
    71     KStorageBus ctrHdBus = type.GetRecommendedHdStorageBus();
    72     KStorageControllerType dvdStorageControllerType = type.GetRecommendedDvdStorageController();
    73     KStorageControllerType hdStorageControllerType = type.GetRecommendedHdStorageController();
    74     CMediumAttachment hda = ctrHdBus != ctrDvdBus || hdStorageControllerType != dvdStorageControllerType ?
    75                             machine.GetMediumAttachment(VBoxVMSettingsHD::tr("Storage Controller 1"), iPort, iDevice) :
    76                             machine.GetMediumAttachment(VBoxVMSettingsHD::tr("Storage Controller"), iPort, iDevice);
    77     return !hda.isNull() && hda.GetType() == KDeviceType_HardDisk;
     70    /* Determine machine 'OS type': */
     71    const CGuestOSType &osType = vbox.GetGuestOSType(machine.GetOSTypeId());
     72    /* Determine recommended controller's 'bus' & 'type': */
     73    KStorageBus hdCtrBus = osType.GetRecommendedHdStorageBus();
     74    KStorageControllerType hdCtrType = osType.GetRecommendedHdStorageController();
     75    /* Enumerate attachments vector: */
     76    const CMediumAttachmentVector &attachments = machine.GetMediumAttachments();
     77    for (int i = 0; i < attachments.size(); ++i)
     78    {
     79        /* Get current attachment: */
     80        const CMediumAttachment &attachment = attachments[i];
     81        /* Determine attachment's controller: */
     82        const CStorageController &controller = machine.GetStorageControllerByName(attachment.GetController());
     83        /* If controller's 'bus' & 'type' are recommended and attachment's 'type' is 'hard disk': */
     84        if (controller.GetBus() == hdCtrBus &&
     85            controller.GetControllerType() == hdCtrType &&
     86            attachment.GetType() == KDeviceType_HardDisk)
     87        {
     88            /* Set the result to 'true': */
     89            fIsBootHardDiskAttached = true;
     90            break;
     91        }
     92    }
     93    /* Return result: */
     94    return fIsBootHardDiskAttached;
    7895}
    7996
     
    97114
    98115    /* Hide unnecessary text labels */
    99     bool fIsDefaultHDAttached = UIFirstRunWzd::isDefaultHardDiskAttached(machine);
    100     m_pPage1Text1Var1->setHidden(!fIsDefaultHDAttached);
    101     m_pPage1Text1Var2->setHidden(fIsDefaultHDAttached);
     116    bool fIsBootHDAttached = UIFirstRunWzd::isBootHardDiskAttached(machine);
     117    m_pPage1Text1Var1->setHidden(!fIsBootHDAttached);
     118    m_pPage1Text1Var2->setHidden(fIsBootHDAttached);
    102119}
    103120
     
    160177
    161178    /* Hide unnecessary text labels */
    162     bool fIsDefaultHDAttached = UIFirstRunWzd::isDefaultHardDiskAttached(machine);
    163     m_pPage2Text1Var1->setHidden(!fIsDefaultHDAttached);
    164     m_pPage2Text1Var2->setHidden(fIsDefaultHDAttached);
     179    bool fIsBootHDAttached = UIFirstRunWzd::isBootHardDiskAttached(machine);
     180    m_pPage2Text1Var1->setHidden(!fIsBootHDAttached);
     181    m_pPage2Text1Var2->setHidden(fIsBootHDAttached);
    165182
    166183    /* Assign media selector attributes */
     
    237254
    238255    /* Hide unnecessary text labels */
    239     bool fIsDefaultHDAttached = UIFirstRunWzd::isDefaultHardDiskAttached(machine);
    240     m_pPage3Text1Var1->setHidden(!fIsDefaultHDAttached);
    241     m_pPage3Text1Var2->setHidden(fIsDefaultHDAttached);
    242     m_pPage3Text2Var1->setHidden(!fIsDefaultHDAttached);
    243     m_pPage3Text2Var2->setHidden(fIsDefaultHDAttached);
     256    bool fIsBootHDAttached = UIFirstRunWzd::isBootHardDiskAttached(machine);
     257    m_pPage3Text1Var1->setHidden(!fIsBootHDAttached);
     258    m_pPage3Text1Var2->setHidden(fIsBootHDAttached);
     259    m_pPage3Text2Var1->setHidden(!fIsBootHDAttached);
     260    m_pPage3Text2Var2->setHidden(fIsBootHDAttached);
    244261}
    245262
     
    293310bool UIFirstRunWzdPage3::insertDevice()
    294311{
    295     /* Composing default controller name */
     312    /* Get 'vbox' global object: */
     313    CVirtualBox vbox = vboxGlobal().virtualBox();
     314    /* Determine machine 'OS type': */
     315    const CGuestOSType &osType = vbox.GetGuestOSType(m_Machine.GetOSTypeId());
     316    /* Determine recommended controller's 'bus' & 'type': */
     317    KStorageBus dvdCtrBus = osType.GetRecommendedDvdStorageBus();
     318    KStorageControllerType dvdCtrType = osType.GetRecommendedDvdStorageController();
     319    /* Declare null 'dvd' attachment: */
     320    CMediumAttachment cda;
     321    /* Enumerate attachments vector: */
     322    const CMediumAttachmentVector &attachments = m_Machine.GetMediumAttachments();
     323    for (int i = 0; i < attachments.size(); ++i)
     324    {
     325        /* Get current attachment: */
     326        const CMediumAttachment &attachment = attachments[i];
     327        /* Determine attachment's controller: */
     328        const CStorageController &controller = m_Machine.GetStorageControllerByName(attachment.GetController());
     329        /* If controller's 'bus' & 'type' are recommended and attachment's 'type' is 'dvd': */
     330        if (controller.GetBus() == dvdCtrBus &&
     331            controller.GetControllerType() == dvdCtrType &&
     332            attachment.GetType() == KDeviceType_DVD)
     333        {
     334            /* Remember attachment: */
     335            cda = attachment;
     336            break;
     337        }
     338    }
     339    AssertMsg(!cda.isNull(), ("Storage Controller is NOT properly configured!\n"));
     340    /* Get chosen 'dvd' medium to mount: */
    296341    QString mediumId = field("id").toString();
    297     LONG iPort = 1;
    298     LONG iDevice = 0;
    299     QString strCtnName = VBoxVMSettingsHD::tr("Storage Controller");
    300     CMediumAttachment cda = m_Machine.GetMediumAttachment(strCtnName, iPort, iDevice);
    301     AssertMsg(!cda.isNull() && cda.GetType() == KDeviceType_DVD,
    302               ("Storage Controller is NOT properly configured!\n"));
    303     /* Mount medium to the predefined port/device */
    304     m_Machine.MountMedium(strCtnName, iPort, iDevice, mediumId, false /* force */);
     342    /* Mount medium to the predefined port/device: */
     343    m_Machine.MountMedium(cda.GetController(), cda.GetPort(), cda.GetDevice(), mediumId, false /* force */);
    305344    if (m_Machine.isOk())
    306345        return true;
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