VirtualBox

Changeset 90259 in vbox


Ignore:
Timestamp:
Jul 20, 2021 12:30:18 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145798
Message:

FE/Qt: bugref:9996. Fixing UIWizardNewVMPageExpert::validatePage().

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm
Files:
3 edited

Legend:

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

    r90252 r90259  
    3636#include "UIMediumSizeEditor.h"
    3737#include "UIMessageCenter.h"
    38 #include "UIWizardNewVD.h"
    3938#include "UIWizardNewVMDiskPageBasic.h"
    4039
     
    4241#include "CGuestOSType.h"
    4342#include "CSystemProperties.h"
     43
     44/* Other VBox includes: */
     45#include <iprt/path.h>
     46
    4447
    4548QString UIWizardNewVMDiskPage::defaultExtension(const CMediumFormat &mediumFormatRef)
     
    107110        return QUuid();
    108111    return uMediumId;
     112}
     113
     114bool UIWizardNewVMDiskPage::checkFATSizeLimitation(const qulonglong uVariant, const QString &strMediumPath, const qulonglong uSize)
     115{
     116    /* If the hard disk is split into 2GB parts then no need to make further checks: */
     117    if (uVariant & KMediumVariant_VmdkSplit2G)
     118        return true;
     119
     120    RTFSTYPE enmType;
     121    int rc = RTFsQueryType(QFileInfo(strMediumPath).absolutePath().toLatin1().constData(), &enmType);
     122    if (RT_SUCCESS(rc))
     123    {
     124        if (enmType == RTFSTYPE_FAT)
     125        {
     126            /* Limit the medium size to 4GB. minus 128 MB for file overhead: */
     127            qulonglong fatLimit = _4G - _128M;
     128            if (uSize >= fatLimit)
     129                return false;
     130        }
     131    }
     132
     133    return true;
    109134}
    110135
     
    270295
    271296    if (m_pMediumSizeEditorLabel)
    272         m_pMediumSizeEditorLabel->setText(UIWizardNewVD::tr("D&isk Size:"));
     297        m_pMediumSizeEditorLabel->setText(UIWizardNewVM::tr("D&isk Size:"));
    273298
    274299    if (m_pFixedCheckBox)
    275300    {
    276         m_pFixedCheckBox->setText(UIWizardNewVD::tr("Pre-allocate &Full Size"));
    277         m_pFixedCheckBox->setToolTip(UIWizardNewVD::tr("<p>When checked, the virtual disk image will be fully allocated at "
     301        m_pFixedCheckBox->setText(UIWizardNewVM::tr("Pre-allocate &Full Size"));
     302        m_pFixedCheckBox->setToolTip(UIWizardNewVM::tr("<p>When checked, the virtual disk image will be fully allocated at "
    278303                                                       "VM creation time, rather than being allocated dynamically at VM run-time.</p>"));
    279304    }
     
    281306    /* Translate rich text labels: */
    282307    if (m_pDescriptionLabel)
    283         m_pDescriptionLabel->setText(UIWizardNewVD::tr("Please choose whether the new virtual hard disk file should grow as it is used "
     308        m_pDescriptionLabel->setText(UIWizardNewVM::tr("Please choose whether the new virtual hard disk file should grow as it is used "
    284309                                                       "(dynamically allocated) or if it should be created at its maximum size (fixed size)."));
    285310    if (m_pDynamicLabel)
    286         m_pDynamicLabel->setText(UIWizardNewVD::tr("<p>A <b>dynamically allocated</b> hard disk file will only use space "
     311        m_pDynamicLabel->setText(UIWizardNewVM::tr("<p>A <b>dynamically allocated</b> hard disk file will only use space "
    287312                                                   "on your physical hard disk as it fills up (up to a maximum <b>fixed size</b>), "
    288313                                                   "although it will not shrink again automatically when space on it is freed.</p>"));
    289314    if (m_pFixedLabel)
    290         m_pFixedLabel->setText(UIWizardNewVD::tr("<p>A <b>fixed size</b> hard disk file may take longer to create on some "
     315        m_pFixedLabel->setText(UIWizardNewVM::tr("<p>A <b>fixed size</b> hard disk file may take longer to create on some "
    291316                                                 "systems but is often faster to use.</p>"));
    292317}
     
    429454        }
    430455        /* Check FAT size limitation of the host hard drive: */
    431         fResult = UIWizardNewVDPageBaseSizeLocation::checkFATSizeLimitation(pWizard->mediumVariant(),
    432                                                                             pWizard->mediumPath(),
    433                                                                             pWizard->mediumSize());
     456        fResult = UIWizardNewVMDiskPage::checkFATSizeLimitation(pWizard->mediumVariant(),
     457                                                                strMediumPath,
     458                                                                pWizard->mediumSize());
    434459        if (!fResult)
    435460        {
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMDiskPageBasic.h

    r90092 r90259  
    6161                                QWidget *pCaller);
    6262    QString absoluteFilePath(const QString &strFileName, const QString &strPath);
     63    bool checkFATSizeLimitation(const qulonglong uVariant, const QString &strMediumPath, const qulonglong uSize);
    6364}
    6465
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp

    r90252 r90259  
    4747#include "UIWizardNewVMPageExpert.h"
    4848#include "UIWizardNewVMNameOSTypePageBasic.h"
    49 
    5049
    5150/* COM includes: */
     
    596595    if (m_enmSelectedDiskSource == SelectedDiskSource_New)
    597596    {
    598 
    599597        qulonglong uSize = pWizard->mediumSize();
    600598        if( uSize >= m_uMediumSizeMin && uSize <= m_uMediumSizeMax)
     
    612610bool UIWizardNewVMPageExpert::validatePage()
    613611{
     612    UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
     613    AssertReturn(pWizard, false);
    614614    bool fResult = true;
    615615
    616     // if (selectedDiskSource() == SelectedDiskSource_New)
    617     // {
    618     //     /* Check if the path we will be using for hard drive creation exists: */
    619     //     const QString strMediumPath(fieldImp("mediumPath").toString());
    620     //     fResult = !QFileInfo(strMediumPath).exists();
    621     //     if (!fResult)
    622     //     {
    623     //         msgCenter().cannotOverwriteHardDiskStorage(strMediumPath, this);
    624     //         return fResult;
    625     //     }
    626     //     /* Check FAT size limitation of the host hard drive: */
    627     //     fResult = UIWizardNewVDPageBaseSizeLocation::checkFATSizeLimitation(fieldImp("mediumVariant").toULongLong(),
    628     //                                                          fieldImp("mediumPath").toString(),
    629     //                                                          fieldImp("mediumSize").toULongLong());
    630     //     if (!fResult)
    631     //     {
    632     //         msgCenter().cannotCreateHardDiskStorageInFAT(strMediumPath, this);
    633     //         return fResult;
    634     //     }
    635     // }
    636 
    637     // startProcessing();
    638     // UIWizardNewVM *pWizard = wizardImp();
    639     // AssertReturn(pWizard, false);
    640     // if (selectedDiskSource() == SelectedDiskSource_New)
    641     // {
    642     //     /* Try to create the hard drive:*/
    643     //     fResult = pWizard->createVirtualDisk();
    644     //     /*Don't show any error message here since UIWizardNewVM::createVirtualDisk already does so: */
    645     //     if (!fResult)
    646     //         return fResult;
    647     // }
    648 
    649     // fResult = pWizard->createVM();
    650     // /* Try to delete the hard disk: */
    651     // if (!fResult)
    652     //     pWizard->deleteVirtualDisk();
    653 
    654     // endProcessing();
     616    if (m_enmSelectedDiskSource == SelectedDiskSource_New)
     617    {
     618        /* Check if the path we will be using for hard drive creation exists: */
     619        const QString &strMediumPath = pWizard->mediumPath();
     620        fResult = !QFileInfo(strMediumPath).exists();
     621        if (!fResult)
     622        {
     623            msgCenter().cannotOverwriteHardDiskStorage(strMediumPath, this);
     624            return fResult;
     625        }
     626        qulonglong uSize = pWizard->mediumSize();
     627        qulonglong uVariant = pWizard->mediumVariant();
     628        /* Check FAT size limitation of the host hard drive: */
     629        fResult =  UIWizardNewVMDiskPage::checkFATSizeLimitation(uVariant, strMediumPath, uSize);
     630        if (!fResult)
     631        {
     632            msgCenter().cannotCreateHardDiskStorageInFAT(strMediumPath, this);
     633            return fResult;
     634        }
     635    }
     636
     637    if (m_enmSelectedDiskSource == SelectedDiskSource_New)
     638    {
     639        /* Try to create the hard drive:*/
     640        fResult = pWizard->createVirtualDisk();
     641        /*Don't show any error message here since UIWizardNewVM::createVirtualDisk already does so: */
     642        if (!fResult)
     643            return fResult;
     644    }
     645
     646    fResult = pWizard->createVM();
     647    /* Try to delete the hard disk: */
     648    if (!fResult)
     649        pWizard->deleteVirtualDisk();
    655650
    656651    return fResult;
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