VirtualBox

Changeset 107119 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 22, 2024 1:04:52 PM (8 weeks ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9996. A missing check for the uniqueness of the guest machine folder has been added.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.cpp

    r106061 r107119  
    2828/* Qt includes: */
    2929#include <QComboBox>
     30#include <QDir>
    3031#include <QGridLayout>
    3132#include <QLabel>
     
    167168}
    168169
     170QString UINameAndSystemEditor::fullPath() const
     171{
     172    QDir dir(path());
     173    QString strFullPath = dir.filePath(name());
     174    return QDir::cleanPath(strFullPath);
     175}
     176
    169177void UINameAndSystemEditor::setISOImagePath(const QString &strPath)
    170178{
     
    234242}
    235243
    236 void UINameAndSystemEditor::markNameEditor(bool fError)
     244void UINameAndSystemEditor::markNameEditor(bool fError, const QString &strErrorMessage, const QString &strNoErrorMessage)
    237245{
    238246    if (m_pEditorName)
    239         m_pEditorName->mark(fError, tr("Invalid guest machine name"), tr("Guest machine name is valid"));
     247        m_pEditorName->mark(fError, strErrorMessage, strNoErrorMessage);
    240248}
    241249
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.h

    r106061 r107119  
    109109    /** Defines the VM @a strPath. */
    110110    void setPath(const QString &strPath);
    111     /** Returns path string selected by the user. */
     111    /** Returns path string selected by the user. This does not include name().*/
    112112    QString path() const;
     113    /** Returns path and name joined and cleaned. */
     114    QString fullPath() const;
    113115
    114116    /** Sets image path. */
     
    127129
    128130    /** Passes the @p fError to QILineEdit::mark(bool) effectively marking it for error. */
    129     void markNameEditor(bool fError);
     131    void markNameEditor(bool fError, const QString &strErrorMessage, const QString &strNoErrorMessage);
    130132    /** Passes the @p fError and @a strErrorMessage to UIFilePathSelector::mark(bool)
    131133      *  effectively changing the background color and error-text. */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp

    r107108 r107119  
    287287            if (!comHDDController.isNull())
    288288            {
    289                 LONG uPortNumber = portNumberForDevice(comHDDController);
    290                 machine.AttachDevice(comHDDController.GetName(), uPortNumber, 0, KDeviceType_HardDisk, m_virtualDisk);
    291                 if (!machine.isOk())
    292                     UINotificationMessage::cannotAttachDevice(machine, UIMediumDeviceType_HardDisk, m_strMediumPath,
    293                                                               StorageSlot(enmHDDBus, uPortNumber, 0), notificationCenter());
     289                LONG iPortNumber = portNumberForDevice(comHDDController);
     290                if (iPortNumber != -1)
     291                {
     292                    machine.AttachDevice(comHDDController.GetName(), iPortNumber, 0, KDeviceType_HardDisk, m_virtualDisk);
     293                    if (!machine.isOk())
     294                        UINotificationMessage::cannotAttachDevice(machine, UIMediumDeviceType_HardDisk, m_strMediumPath,
     295                                                                  StorageSlot(enmHDDBus, iPortNumber, 0), notificationCenter());
     296                }
    294297            }
    295298        }
     
    319322                    UINotificationMessage::cannotOpenMedium(vbox, strISOFilePath, notificationCenter());
    320323            }
    321             LONG uPortNumber = portNumberForDevice(comDVDController);
    322             machine.AttachDevice(comDVDController.GetName(), uPortNumber, 0, KDeviceType_DVD, opticalDisk);
    323             if (!machine.isOk())
    324                 UINotificationMessage::cannotAttachDevice(machine, UIMediumDeviceType_DVD, QString(),
    325                                                           StorageSlot(enmDVDBus, 1, 0), notificationCenter());
     324            LONG iPortNumber = portNumberForDevice(comDVDController);
     325            if (iPortNumber != -1)
     326            {
     327                machine.AttachDevice(comDVDController.GetName(), iPortNumber, 0, KDeviceType_DVD, opticalDisk);
     328                if (!machine.isOk())
     329                    UINotificationMessage::cannotAttachDevice(machine, UIMediumDeviceType_DVD, QString(),
     330                                                              StorageSlot(enmDVDBus, 1, 0), notificationCenter());
     331            }
    326332        }
    327333        /* Save machine settings here because  portNumberForDevice needs to inquiry port attachments of the controller: */
     
    865871    }
    866872
    867 
    868873    if (!comController.isOk())
    869874    {
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMExpertPage.cpp

    r106118 r107119  
    468468    if (m_pNameAndSystemEditor)
    469469    {
    470         m_pNameAndSystemEditor->markNameEditor(m_pNameAndSystemEditor->name().isEmpty());
     470        m_pNameAndSystemEditor->markNameEditor(m_pNameAndSystemEditor->name().isEmpty(),
     471                                               tr("Guest machine name cannot be empty"), tr("Guest machine name is valid"));
    471472        m_pNameAndSystemEditor->markImageEditor(!UIWizardNewVMNameOSTypeCommon::checkISOFile(m_pNameAndSystemEditor),
    472473                                                UIWizardNewVM::tr("Invalid file path or unreadable file"),
    473474                                                UIWizardNewVM::tr("File path is valid"));
     475        m_pNameAndSystemEditor->markNameEditor((QDir(m_pNameAndSystemEditor->fullPath()).exists()),
     476                                               tr("Guest machine path is not unique"), tr("Guest machine name is valid"));
    474477    }
    475478    UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
     
    629632                                         UIIconPool::iconSet(":/status_error_16px.png"),
    630633                                         UIWizardNewVM::tr("Invalid ISO file"));
     634            fIsComplete = false;
     635        }
     636        if (QDir(m_pNameAndSystemEditor->fullPath()).exists())
     637        {
     638            m_pToolBox->setPageTitleIcon(ExpertToolboxItems_NameAndOSType,
     639                                         UIIconPool::iconSet(":/status_error_16px.png"),
     640                                         UIWizardNewVM::tr("Guest machine path is not unique"));
    631641            fIsComplete = false;
    632642        }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePage.cpp

    r107002 r107119  
    523523    if (m_pNameAndSystemEditor->name().isEmpty())
    524524        return false;
     525    if (QDir(m_pNameAndSystemEditor->fullPath()).exists())
     526        return false;
    525527    return UIWizardNewVMNameOSTypeCommon::checkISOFile(m_pNameAndSystemEditor);
    526528}
     
    766768    if (m_pNameAndSystemEditor)
    767769    {
    768         m_pNameAndSystemEditor->markNameEditor(m_pNameAndSystemEditor->name().isEmpty());
     770        m_pNameAndSystemEditor->markNameEditor(m_pNameAndSystemEditor->name().isEmpty(),
     771                                               tr("Guest machine name cannot be empty"), tr("Guest machine name is valid"));
     772        m_pNameAndSystemEditor->markNameEditor((QDir(m_pNameAndSystemEditor->fullPath()).exists()),
     773                                               tr("Guest machine path is not unique"), tr("Guest machine name is valid"));
    769774        m_pNameAndSystemEditor->markImageEditor(!UIWizardNewVMNameOSTypeCommon::checkISOFile(m_pNameAndSystemEditor),
    770775                                                UIWizardNewVM::tr("Invalid file path or unreadable file"),
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