VirtualBox

Changeset 73130 in vbox


Ignore:
Timestamp:
Jul 13, 2018 4:29:34 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
123718
Message:

FE/Qt: bugref:9206: Make UINameAndSystemEditor handle unknown guest OS families and types.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r73117 r73130  
    303303#ifdef VBOX_WITH_VIDEOHWACCEL
    304304    /* Check if 2D video acceleration supported by the guest OS type: */
    305     const QString strGuestOSTypeFamily = m_comGuestOSType.GetFamilyId();
     305    const QString strGuestOSTypeFamily = m_comGuestOSType.isNotNull() ? m_comGuestOSType.GetFamilyId() : QString();
    306306    m_f2DVideoAccelerationSupported = strGuestOSTypeFamily == "Windows";
    307307#endif
    308308#ifdef VBOX_WITH_CRHGSMI
    309309    /* Check if WDDM mode supported by the guest OS type: */
    310     const QString strGuestOSTypeId = m_comGuestOSType.GetId();
     310    const QString strGuestOSTypeId = m_comGuestOSType.isNotNull() ? m_comGuestOSType.GetId() : QString();
    311311    m_fWddmModeSupported = VBoxGlobal::isWddmCompatibleOsType(strGuestOSTypeId);
    312312#endif
     
    12591259    QStringList excludingOSList = QStringList()
    12601260        << "Other" << "DOS" << "Netware" << "L4" << "QNX" << "JRockitVE";
    1261     if (excludingOSList.contains(m_comGuestOSType.GetId()))
     1261    if (m_comGuestOSType.isNull() || excludingOSList.contains(m_comGuestOSType.GetId()))
    12621262        fResult = false;
    12631263
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp

    r72177 r73130  
    143143{
    144144    AssertPtrReturn(m_pNameAndSystemEditor, false);
    145     return m_pNameAndSystemEditor->type().GetIs64Bit();
     145    return   m_pNameAndSystemEditor->type().isNotNull()
     146           ? m_pNameAndSystemEditor->type().GetIs64Bit()
     147           : false;
    146148}
    147149
     
    150152{
    151153    AssertPtrReturn(m_pNameAndSystemEditor, false);
    152     return m_pNameAndSystemEditor->type().GetFamilyId() == "Windows";
     154    return m_pNameAndSystemEditor->familyId() == "Windows";
    153155}
    154156#endif /* VBOX_WITH_VIDEOHWACCEL */
     
    248250    AssertPtrReturnVoid(m_pNameAndSystemEditor);
    249251    m_pNameAndSystemEditor->setName(oldGeneralData.m_strName);
    250     m_pNameAndSystemEditor->setType(vboxGlobal().vmGuestOSType(oldGeneralData.m_strGuestOsTypeId));
     252    m_pNameAndSystemEditor->setTypeId(oldGeneralData.m_strGuestOsTypeId);
    251253
    252254    /* Load old 'Advanced' data from the cache: */
     
    286288    AssertPtrReturnVoid(m_pNameAndSystemEditor);
    287289    newGeneralData.m_strName = m_pNameAndSystemEditor->name();
    288     newGeneralData.m_strGuestOsTypeId = m_pNameAndSystemEditor->type().GetId();
     290    newGeneralData.m_strGuestOsTypeId = m_pNameAndSystemEditor->typeId();
    289291
    290292    /* Gather new 'Advanced' data: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.cpp

    r73129 r73130  
    8585}
    8686
     87void UINameAndSystemEditor::setTypeId(const QString &strTypeId, const QString &strFamilyId /* = QString() */)
     88{
     89    AssertMsgReturnVoid(!strTypeId.isNull(), ("Null guest OS type ID"));
     90
     91    /* Save values: */
     92    m_strTypeId = strTypeId;
     93    m_strFamilyId = strFamilyId;
     94
     95    /* If family ID isn't null: */
     96    if (!m_strFamilyId.isNull())
     97    {
     98        /* Serch for corresponding family ID index: */
     99        int iFamilyIndex = m_pComboFamily->findData(m_strFamilyId, TypeID);
     100
     101        /* If that family ID isn't present, we have to add it: */
     102        if (iFamilyIndex == -1)
     103        {
     104            /* Append family ID to corresponding combo: */
     105            m_pComboFamily->addItem(m_strFamilyId);
     106            m_pComboFamily->setItemData(m_pComboFamily->count() - 1, m_strFamilyId, TypeID);
     107
     108            /* Serch for corresponding family ID index again: */
     109            iFamilyIndex = m_pComboFamily->findData(m_strFamilyId, TypeID);
     110
     111            /* Append the type cache: */
     112            m_types[m_strFamilyId] = QList<UIGuestOSType>();
     113            UIGuestOSType guiType;
     114            guiType.typeId = m_strTypeId;
     115            guiType.typeDescription = m_strTypeId;
     116            guiType.is64bit = false;
     117            m_types[m_strFamilyId] << guiType;
     118        }
     119
     120        /* Choose if we have something to: */
     121        if (iFamilyIndex != -1)
     122        {
     123            m_pComboFamily->setCurrentIndex(iFamilyIndex);
     124            sltFamilyChanged(m_pComboFamily->currentIndex());
     125        }
     126    }
     127
     128    /* Serch for corresponding type ID index: */
     129    int iTypeIndex = m_pComboType->findData(m_strTypeId, TypeID);
     130
     131    /* If that type ID isn't present, we have to add it: */
     132    if (iTypeIndex == -1)
     133    {
     134        /* Serch for "Other" family ID index: */
     135        m_strFamilyId = "Other";
     136        int iFamilyIndex = m_pComboFamily->findData(m_strFamilyId, TypeID);
     137
     138        /* If that family ID is present: */
     139        if (iFamilyIndex != -1)
     140        {
     141            /* Append the type cache: */
     142            UIGuestOSType guiType;
     143            guiType.typeId = m_strTypeId;
     144            guiType.typeDescription = m_strTypeId;
     145            guiType.is64bit = false;
     146            m_types[m_strFamilyId] << guiType;
     147
     148            /* Choose required element: */
     149            m_pComboFamily->setCurrentIndex(iFamilyIndex);
     150            sltFamilyChanged(m_pComboFamily->currentIndex());
     151        }
     152
     153        /* Serch for corresponding type ID index again: */
     154        iTypeIndex = m_pComboType->findData(m_strTypeId, TypeID);
     155    }
     156
     157    /* Choose if we have something to: */
     158    if (iTypeIndex != -1)
     159    {
     160        m_pComboType->setCurrentIndex(iTypeIndex);
     161        sltTypeChanged(m_pComboType->currentIndex());
     162    }
     163}
     164
     165QString UINameAndSystemEditor::typeId() const
     166{
     167    return m_strTypeId;
     168}
     169
     170QString UINameAndSystemEditor::familyId() const
     171{
     172    return m_strFamilyId;
     173}
     174
    87175CGuestOSType UINameAndSystemEditor::type() const
    88176{
    89     return m_enmType;
     177    return vboxGlobal().vmGuestOSType(typeId(), familyId());
    90178}
    91179
     
    99187        return;
    100188
    101     /* Initialize variables: */
    102     const QString strFamilyId = enmType.GetFamilyId();
    103     const QString strTypeId = enmType.GetId();
    104 
    105     /* Get/check family index: */
    106     const int iFamilyIndex = m_pComboFamily->findData(strFamilyId, TypeID);
    107     AssertMsg(iFamilyIndex != -1, ("Invalid family ID: '%s'", strFamilyId.toLatin1().constData()));
    108     if (iFamilyIndex != -1)
    109         m_pComboFamily->setCurrentIndex(iFamilyIndex);
    110 
    111     /* Get/check type index: */
    112     const int iTypeIndex = m_pComboType->findData(strTypeId, TypeID);
    113     AssertMsg(iTypeIndex != -1, ("Invalid type ID: '%s'", strTypeId.toLatin1().constData()));
    114     if (iTypeIndex != -1)
    115         m_pComboType->setCurrentIndex(iTypeIndex);
     189    /* Pass to function above: */
     190    setTypeId(enmType.GetId(), enmType.GetFamilyId());
    116191}
    117192
     
    141216
    142217    /* Populate combo-box with OS types related to currently selected family id: */
    143     foreach (const CGuestOSType &comType, vboxGlobal().vmGuestOSTypeList(strFamilyId))
     218    foreach (const UIGuestOSType &guiType, m_types.value(strFamilyId))
    144219    {
    145220        /* Skip 64bit OS types if hardware virtualization or long mode is not supported: */
    146         if (comType.GetIs64Bit() && (!m_fSupportsHWVirtEx || !m_fSupportsLongMode))
     221        if (guiType.is64bit && (!m_fSupportsHWVirtEx || !m_fSupportsLongMode))
    147222            continue;
    148223        const int iIndex = m_pComboType->count();
    149         m_pComboType->insertItem(iIndex, comType.GetDescription());
    150         m_pComboType->setItemData(iIndex, comType.GetId(), TypeID);
     224        m_pComboType->insertItem(iIndex, guiType.typeDescription);
     225        m_pComboType->setItemData(iIndex, guiType.typeId, TypeID);
    151226    }
    152227
     
    195270    const QString strTypeId = m_pComboType->itemData(iIndex, TypeID).toString();
    196271    const QString strFamilyId = m_pComboFamily->itemData(m_pComboFamily->currentIndex(), TypeID).toString();
    197 
    198     /* Save the new selected OS type: */
    199     m_enmType = vboxGlobal().vmGuestOSType(strTypeId, strFamilyId);
    200272
    201273    /* Update selected type pixmap: */
     
    364436void UINameAndSystemEditor::prepareFamilyCombo()
    365437{
    366     /* Populate VM OS family combo: */
    367     const QList<QString> &familyIDs = vboxGlobal().vmGuestOSFamilyIDs();
    368     for (int i = 0; i < familyIDs.size(); ++i)
    369     {
    370         const QString &strFamilyId = familyIDs.at(i);
     438    /* Acquire family IDs: */
     439    m_familyIDs = vboxGlobal().vmGuestOSFamilyIDs();
     440
     441    /* For each known family ID: */
     442    for (int i = 0; i < m_familyIDs.size(); ++i)
     443    {
     444        const QString &strFamilyId = m_familyIDs.at(i);
     445
     446        /* Append VM OS family combo: */
    371447        m_pComboFamily->insertItem(i, vboxGlobal().vmGuestOSFamilyDescription(strFamilyId));
    372448        m_pComboFamily->setItemData(i, strFamilyId, TypeID);
     449
     450        /* Fill in the type cache: */
     451        m_types[strFamilyId] = QList<UIGuestOSType>();
     452        foreach (const CGuestOSType &comType, vboxGlobal().vmGuestOSTypeList(strFamilyId))
     453        {
     454            UIGuestOSType guiType;
     455            guiType.typeId = comType.GetId();
     456            guiType.typeDescription = comType.GetDescription();
     457            guiType.is64bit = comType.GetIs64Bit();
     458            m_types[strFamilyId] << guiType;
     459        }
    373460    }
    374461
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.h

    r73129 r73130  
    4444    Q_PROPERTY(CGuestOSType type READ type WRITE setType);
    4545
     46    /** Simple struct representing CGuestOSType cache. */
     47    struct UIGuestOSType
     48    {
     49        QString typeId;
     50        QString typeDescription;
     51        bool is64bit;
     52    };
     53
    4654signals:
    4755
     
    6674    /** Defines the VM @a strName. */
    6775    void setName(const QString &strName);
     76
     77    /** Defines the VM OS @a strTypeId and @a strFamilyId if passed. */
     78    void setTypeId(const QString &strTypeId, const QString &strFamilyId = QString());
     79    /** Returns the VM OS type ID. */
     80    QString typeId() const;
     81    /** Returns the VM OS family ID. */
     82    QString familyId() const;
    6883
    6984    /** Returns the VM OS type. */
     
    104119    /** @} */
    105120
    106     /** Holds the VM OS type. */
    107     CGuestOSType            m_enmType;
     121    /** Holds the current family ID list. */
     122    QStringList  m_familyIDs;
     123
     124    /** Holds the current type cache. */
     125    QMap<QString, QList<UIGuestOSType> >  m_types;
     126
     127    /** Holds the VM OS type ID. */
     128    QString  m_strTypeId;
     129    /** Holds the VM OS family ID. */
     130    QString  m_strFamilyId;
     131
    108132    /** Holds the currently chosen OS type IDs on per-family basis. */
    109133    QMap<QString, QString>  m_currentIds;
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