VirtualBox

Changeset 96638 in vbox


Ignore:
Timestamp:
Sep 7, 2022 4:51:44 PM (2 years ago)
Author:
vboxsync
Message:

FE/Qt: The detected OS type ID can be used directly as the guest OS type for the new VM, it certainly makes no sense to treat it as name and run it thru the gs_OSTypePattern voodoo. Since this started with a 64-bit XP ISO being typed as 32-bit XP because gs_OSTypePattern didn't include any 64-bit XP entry, I've added one and hacked around the 32-bit preference in UIWizardNewVMNameOSTypeCommon::guessOSTypeFromName instead by having an exclusion regex for the + '64' to the name. bugref:9515

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePage.cpp

    r96430 r96638  
    6464    { QRegularExpression( "(Wi.*NT)|(NT[-._v]*4)",           QRegularExpression::CaseInsensitiveOption), "WindowsNT4" },
    6565    { QRegularExpression( "NT[-._v]*3[.,]*[51x]",            QRegularExpression::CaseInsensitiveOption), "WindowsNT3x" },
    66     /* Note: Do not automatically set WindowsXP_64 on 64-bit hosts, as Windows XP 64-bit
    67      *       is extremely rare -- most users never heard of it even. So always default to 32-bit. */
    68     { QRegularExpression("((Wi.*XP)|(XP)).*",                QRegularExpression::CaseInsensitiveOption), "WindowsXP" },
     66    { QRegularExpression("(Wi.*XP.*64)|(XP.*64)",            QRegularExpression::CaseInsensitiveOption), "WindowsXP_64" },
     67    { QRegularExpression("(XP)",                             QRegularExpression::CaseInsensitiveOption), "WindowsXP" },
    6968    { QRegularExpression("((Wi.*2003)|(W2K3)|(Win2K3)).*64", QRegularExpression::CaseInsensitiveOption), "Windows2003_64" },
    7069    { QRegularExpression("((Wi.*2003)|(W2K3)|(Win2K3)).*32", QRegularExpression::CaseInsensitiveOption), "Windows2003" },
     
    260259};
    261260
     261static const QRegularExpression gs_Prefer32BitNamePatterns = QRegularExpression("(XP)", QRegularExpression::CaseInsensitiveOption);
     262
     263
    262264bool UIWizardNewVMNameOSTypeCommon::guessOSTypeFromName(UINameAndSystemEditor *pNameAndSystemEditor, QString strNewName)
    263265{
    264266    AssertReturn(pNameAndSystemEditor, false);
    265     /* Append default architecture bit-count (64/32) if not already in the name: */
    266     if (!strNewName.contains("32") && !strNewName.contains("64"))
     267
     268    /* Append default architecture bit-count (64/32) if not already in the name, unless
     269       it's XP or similar which is predominantly 32-bit: */
     270    if (!strNewName.contains("32") && !strNewName.contains("64") && !strNewName.contains(gs_Prefer32BitNamePatterns))
    267271    {
    268272        /** @todo cache this result, no need to re-query it for each keystroke... */
     
    288292{
    289293    AssertReturn(pNameAndSystemEditor, false);
    290     if (strDetectedOSType.isEmpty())
    291     {
    292         pNameAndSystemEditor->setType(uiCommon().vmGuestOSType("Other"));
    293         /* Return false to allow OS type guessing from name. See caller code: */
    294         return false;
    295     }
    296     /* Append 32 as bit-count if the name has no 64 and 32 in the name since API returns a type name with no arch bit count for 32-bit OSs: */
    297     if (!strDetectedOSType.contains("32") && !strDetectedOSType.contains("64"))
    298         strDetectedOSType += "32";
    299 
    300     /* Search for a matching OS type based on the string the user typed already. */
    301     for (size_t i = 0; i < RT_ELEMENTS(gs_OSTypePattern); ++i)
    302     {
    303         if (strDetectedOSType.contains(gs_OSTypePattern[i].pattern))
     294    if (!strDetectedOSType.isEmpty())
     295    {
     296        CGuestOSType const osType = uiCommon().vmGuestOSType(strDetectedOSType);
     297        if (!osType.isNull())
    304298        {
    305 
    306             pNameAndSystemEditor->setType(uiCommon().vmGuestOSType(gs_OSTypePattern[i].pcstId));
     299            pNameAndSystemEditor->setType(osType);
    307300            return true;
    308301        }
    309     }
     302        /* The detectedOSType shall be a valid OS type ID. So, unless the UI is
     303           out of sync with the types in main this shouldn't ever happen. */
     304        AssertFailed();
     305    }
     306    pNameAndSystemEditor->setType(uiCommon().vmGuestOSType("Other"));
     307    /* Return false to allow OS type guessing from name. See caller code: */
     308    /** @todo the caller doesn't actually re-guess from the name, which leaves it
     309     *        with this annoying 'other' selection. */
    310310    return false;
    311311}
     
    617617    if (m_pNameAndSystemEditor)
    618618         m_pNameAndSystemEditor->setEditionNameAndIndices(pWizard->detectedWindowsImageNames(),
    619                                                          pWizard->detectedWindowsImageIndices());
     619                                                          pWizard->detectedWindowsImageIndices());
    620620
    621621    setSkipCheckBoxEnable();
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