VirtualBox

Changeset 92032 in vbox for trunk


Ignore:
Timestamp:
Oct 25, 2021 1:25:10 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9996. Trying to improve cleanup stuff wen vm creatin fails.

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

Legend:

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

    r92024 r92032  
    132132                                       m_strMachineBaseName,
    133133                                       groups, strTypeId, QString());
     134        /* Try to delete the hard disk: */
     135        deleteVirtualDisk();
     136
    134137        if (!vbox.isOk())
    135138        {
     
    164167    if (!vbox.isOk())
    165168    {
     169        /* Try to delete the hard disk: */
     170        deleteVirtualDisk();
    166171        msgCenter().cannotRegisterMachine(vbox, m_machine.GetName(), this);
    167172        return false;
     
    441446        CVirtualBox vbox = uiCommon().virtualBox();
    442447        /* Unregister on failure */
    443         QVector<CMedium> aMedia = m_machine.Unregister(KCleanupMode_UnregisterOnly);   /// @todo replace with DetachAllReturnHardDisksOnly once a progress dialog is in place below
     448        QVector<CMedium> aMedia = m_machine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly);
    444449        if (vbox.isOk())
    445450        {
     
    447452            progress.WaitForCompletion(-1);         /// @todo do this nicely with a progress dialog, this can delete lots of files
    448453        }
    449         return false;
    450     }
    451 
    452     /* Ensure we don't try to delete a newly created virtual hard drive on success: */
     454    }
     455
     456    /* Make sure we detach CMedium wrapper from IMedium pointer to avoid deletion of IMedium as m_virtualDisk is deallocated: */
     457    /* Or in case of IMachine::DeleteConfig IMedium has been already deleted so detach in this case as well:*/
    453458    if (!m_virtualDisk.isNull())
    454459        m_virtualDisk.detach();
    455460
    456     return true;
     461    return success;
    457462}
    458463
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h

    r91593 r92032  
    7979    bool createVM();
    8080    bool createVirtualDisk();
    81     void deleteVirtualDisk();
    8281
    8382    CMedium &virtualDisk();
     
    189188    /** Returns the Id of newly created VM. */
    190189    QUuid createdMachineId() const;
     190    void deleteVirtualDisk();
    191191
    192192    /** @name Variables
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMExpertPage.cpp

    r91616 r92032  
    640640    }
    641641
    642     fResult = pWizard->createVM();
    643     /* Try to delete the hard disk: */
    644     if (!fResult)
    645         pWizard->deleteVirtualDisk();
    646 
    647     return fResult;
     642    return pWizard->createVM();
    648643}
    649644
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMSummaryPage.cpp

    r91294 r92032  
    509509    }
    510510
    511     fResult = pWizard->createVM();
    512     /* Try to delete the hard disk: */
    513     if (!fResult)
    514         pWizard->deleteVirtualDisk();
    515 
    516     return fResult;
     511    return pWizard->createVM();
    517512}
    518513
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