VirtualBox

Ignore:
Timestamp:
May 10, 2018 7:29:57 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
122617
Message:

FE/Qt bugref:6769 Fix the bug causing by incorrect folder cleanup in new vm wizard

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

Legend:

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

    r72183 r72185  
    179179
    180180UIWizardNewVMPage1::UIWizardNewVMPage1(const QString &strGroup)
    181     : m_strGroup(strGroup)
     181    : m_pNameAndSystemEditor(0)
     182    , m_strGroup(strGroup)
     183
    182184{
    183185    CHost host = vboxGlobal().host();
     
    196198        if (strNewName.contains(gs_OSTypePattern[i].pattern))
    197199        {
    198             m_pNameAndSystemEditor->blockSignals(true);
    199             m_pNameAndSystemEditor->setType(vboxGlobal().vmGuestOSType(gs_OSTypePattern[i].pcstId));
    200             m_pNameAndSystemEditor->blockSignals(false);
     200            if (m_pNameAndSystemEditor)
     201            {
     202                m_pNameAndSystemEditor->blockSignals(true);
     203                m_pNameAndSystemEditor->setType(vboxGlobal().vmGuestOSType(gs_OSTypePattern[i].pcstId));
     204                m_pNameAndSystemEditor->blockSignals(false);
     205            }
    201206            break;
    202207        }
     
    207212    /* If the user manually edited the OS type, we didn't want our automatic OS type guessing anymore.
    208213     * So simply disconnect the text-edit signal. */
    209     m_pNameAndSystemEditor->disconnect(SIGNAL(sigNameChanged(const QString &)), thisImp(), SLOT(sltNameChanged(const QString &)));
    210 }
    211 
    212 bool UIWizardNewVMPage1::machineFolderCreated()
    213 {
    214     return !m_strMachineFolder.isEmpty();
    215 }
     214    if (m_pNameAndSystemEditor)
     215        m_pNameAndSystemEditor->disconnect(SIGNAL(sigNameChanged(const QString &)), thisImp(), SLOT(sltNameChanged(const QString &)));
     216}
     217
     218// bool UIWizardNewVMPage1::machineFolderCreated()
     219// {
     220//     return !m_strMachineFolder.isEmpty();
     221// }
    216222
    217223void UIWizardNewVMPage1::composeMachineFilePath()
    218224{
     225    if (!m_pNameAndSystemEditor)
     226        return;
     227    if (m_pNameAndSystemEditor->name().isEmpty() || m_pNameAndSystemEditor->path().isEmpty())
     228        return;
    219229    /* Get VBox: */
    220230    CVirtualBox vbox = vboxGlobal().virtualBox();
     
    239249        return false;
    240250    /* Cleanup previosly created folder if any: */
    241     if (machineFolderCreated() && !cleanupMachineFolder())
     251    if (!cleanupMachineFolder())
    242252    {
    243253        msgCenter().cannotRemoveMachineFolder(m_strMachineFolder, thisImp());
     
    261271        return false;
    262272    }
     273    m_strCreatedFolder = m_strMachineFolder;
    263274    return true;
    264275}
     
    267278{
    268279    /* Make sure folder was previosly created: */
    269     if (m_strMachineFolder.isEmpty())
    270         return false;
    271     /* Try to cleanup folder (and it's predecessors): */
    272     bool fMachineFolderRemoved = QDir().rmpath(m_strMachineFolder);
    273     /* Reset machine folder value: */
    274     if (fMachineFolderRemoved)
    275         m_strMachineFolder = QString();
    276     /* Return cleanup result: */
    277     return fMachineFolderRemoved;
     280    if (!m_strCreatedFolder.isEmpty() && m_strCreatedFolder != m_strMachineFolder)
     281    {
     282        /* Try to cleanup folder (and it's predecessors): */
     283        bool fMachineFolderRemoved = QDir().rmpath(m_strCreatedFolder);
     284        /* Reset machine folder value: */
     285        if (fMachineFolderRemoved)
     286            m_strCreatedFolder = QString();
     287        /* Return cleanup result: */
     288        return fMachineFolderRemoved;
     289    }
     290    return true;
     291}
     292
     293QString UIWizardNewVMPage1::machineFilePath() const
     294{
     295    return m_strMachineFilePath;
     296}
     297
     298void UIWizardNewVMPage1::setMachineFilePath(const QString &strMachineFilePath)
     299{
     300    m_strMachineFilePath = strMachineFilePath;
     301}
     302
     303QString UIWizardNewVMPage1::machineFolder() const
     304{
     305    return m_strMachineFolder;
     306}
     307
     308void UIWizardNewVMPage1::setMachineFolder(const QString &strMachineFolder)
     309{
     310    m_strMachineFolder = strMachineFolder;
     311}
     312
     313QString UIWizardNewVMPage1::machineBaseName() const
     314{
     315    return m_strMachineBaseName;
     316}
     317
     318void UIWizardNewVMPage1::setMachineBaseName(const QString &strMachineBaseName)
     319{
     320    m_strMachineBaseName = strMachineBaseName;
    278321}
    279322
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.h

    r72182 r72185  
    3939
    4040    /* Helping stuff: */
    41     bool machineFolderCreated();
     41    //bool machineFolderCreated();
    4242    bool createMachineFolder();
    4343    bool cleanupMachineFolder();
    4444
    45     QString machineFilePath() const { return m_strMachineFilePath; }
    46     void setMachineFilePath(const QString &strMachineFilePath) { m_strMachineFilePath = strMachineFilePath; }
     45    QString machineFilePath() const;
     46    void setMachineFilePath(const QString &strMachineFilePath);
    4747
    48     /** Returns the machine folder value. */
    49     QString machineFolder() const { return m_strMachineFolder; }
    50     /** Defines the @a strMachineFolder value. */
    51     void setMachineFolder(const QString &strMachineFolder) { m_strMachineFolder = strMachineFolder; }
     48    QString machineFolder() const;
     49    void setMachineFolder(const QString &strMachineFolder);
    5250
    53     /** Returns the machine base-name value. */
    54     QString machineBaseName() const { return m_strMachineBaseName; }
    55     /** Defines the @a strMachineBaseName value. */
    56     void setMachineBaseName(const QString &strMachineBaseName) { m_strMachineBaseName = strMachineBaseName; }
     51    QString machineBaseName() const;
     52    void setMachineBaseName(const QString &strMachineBaseName);
    5753
    5854    /** calls CVirtualBox::ComposeMachineFilename(...) and sets related member variables */
    5955    void composeMachineFilePath();
     56
     57    /** Provides a path selector and a line edit field for path and name entry. */
     58    UINameAndSystemEditor *m_pNameAndSystemEditor;
     59
     60private:
    6061
    6162    /** Full path (including the file name) of the machine's configuration file. */
     
    6364    /** Path of the folder hosting the machine's configuration file. Generated from m_strMachineFilePath. */
    6465    QString m_strMachineFolder;
     66    /** Path of the folder created by this wizard page. Used to remove previously created folders etc. */
     67    QString m_strCreatedFolder;
    6568    /** Base name of the machine is generated from the m_strMachineFilePath. */
    6669    QString m_strMachineBaseName;
    6770
    68     /** Provides a path selector and a line edit field for path and name entry. */
    69     UINameAndSystemEditor *m_pNameAndSystemEditor;
    7071
    7172    QString m_strGroup;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp

    r72177 r72185  
    138138    connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged,
    139139            this, &UIWizardNewVMPageExpert::sltNameChanged);
     140    connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged,
     141            this, &UIWizardNewVMPageExpert::sltPathChanged);
    140142    connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged,
    141143            this, &UIWizardNewVMPageExpert::sltOsTypeChanged);
     
    179181    m_pRamEditor->setValue(type.GetRecommendedRAM());
    180182
    181     /* Broadcast complete-change: */
    182     emit completeChanged();
     183    composeMachineFilePath();
     184    /* Broadcast complete-change: */
     185    emit completeChanged();
     186}
     187
     188void UIWizardNewVMPageExpert::sltPathChanged(const QString &strNewPath)
     189{
     190    composeMachineFilePath();
    183191}
    184192
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.h

    r72177 r72185  
    5959    /* Handlers: */
    6060    void sltNameChanged(const QString &strNewText);
     61    void sltPathChanged(const QString &strNewPath);
    6162    void sltOsTypeChanged();
    6263    void sltRamSliderValueChanged();
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