VirtualBox

Changeset 79574 in vbox for trunk/src


Ignore:
Timestamp:
Jul 7, 2019 11:32:06 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9495: New Cloud VM wizard: A bit of refactoring for cloud creation procedure.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVM.cpp

    r79312 r79574  
    6767bool UIWizardNewCloudVM::createCloudVM()
    6868{
    69     /* Acquire prepared client and description: */
    70     CCloudClient comCloudClient = field("client").value<CCloudClient>();
    71     CVirtualSystemDescription comDescription = field("vsd").value<CVirtualSystemDescription>();
    72     AssertReturn(comCloudClient.isNotNull() && comDescription.isNotNull(), false);
     69    /* Prepare result: */
     70    bool fResult = false;
    7371
    74     /* Initiate cloud VM creation porocedure: */
    75     CProgress comProgress = comCloudClient.LaunchVM(comDescription);
     72    /* Main API request sequence, can be interrupted after any step: */
     73    do
     74    {
     75        /* Acquire prepared client and description: */
     76        CCloudClient comClient = field("client").value<CCloudClient>();
     77        CVirtualSystemDescription comDescription = field("vsd").value<CVirtualSystemDescription>();
     78        AssertReturn(comClient.isNotNull() && comDescription.isNotNull(), false);
    7679
    77     /* Show error message if necessary: */
    78     if (!comCloudClient.isOk())
    79         msgCenter().cannotCreateCloudMachine(comCloudClient, this);
    80     else
    81     {
     80        /* Initiate cloud VM creation procedure: */
     81        CProgress comProgress = comClient.LaunchVM(comDescription);
     82        if (!comClient.isOk())
     83        {
     84            msgCenter().cannotCreateCloudMachine(comClient, this);
     85            break;
     86        }
     87
    8288        /* Show "Create Cloud Machine" progress: */
    83         msgCenter().showModalProgressDialog(comProgress, tr("Create Cloud Machine ..."), ":/progress_new_cloud_vm_90px.png", this, 0);
    84         if (!comProgress.GetCanceled())
     89        msgCenter().showModalProgressDialog(comProgress, tr("Create Cloud Machine ..."),
     90                                            ":/progress_new_cloud_vm_90px.png", this, 0);
     91        if (comProgress.GetCanceled())
     92            break;
     93        if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    8594        {
    86             /* Show error message if necessary: */
    87             if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    88                 msgCenter().cannotCreateCloudMachine(comProgress, this);
    89             else
    90                 return true;
     95            msgCenter().cannotCreateCloudMachine(comProgress, this);
     96            break;
    9197        }
     98
     99        /* Finally, success: */
     100        fResult = true;
    92101    }
     102    while (0);
    93103
    94     /* Failure by default: */
    95     return false;
     104    /* Return result: */
     105    return fResult;
    96106}
    97107
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVM.h

    r79256 r79574  
    5151    virtual void prepare() /* override */;
    5252
    53     /** Create cloud VM. */
     53    /** Create New Cloud VM. */
    5454    bool createCloudVM();
    5555
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