VirtualBox

Changeset 83676 in vbox


Ignore:
Timestamp:
Apr 10, 2020 5:50:30 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: Adjust add cloud VM transaction to make sure wizard provides Chooser pane with added objects to be able insert them instantly; This is a WORKAROUND to desired sequence cause register cloud VM event isn't exist yet.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r83674 r83676  
    938938        /* Execute wizard: */
    939939        pWizard->exec();
     940
     941        // WORKAROUND:
     942        // Hehey! Now we have to inject created VM nodes and then rebuild tree for the main root node ourselves
     943        // cause there is no corresponding event yet. Later this to be done in corresponding event handler instead.
     944        foreach (const CCloudMachine &comMachine, pWizard->machines())
     945        {
     946            // Create new node:
     947            UIChooserNodeMachine *pNode = new UIChooserNodeMachine(pGroup->node(),
     948                                                                   false /* favorite */,
     949                                                                   pGroup->node()->nodes().size() /* position */,
     950                                                                   comMachine);
     951            // Request async node update:
     952            pNode->cache()->toCloud()->updateInfoAsync(false /* delayed? */);
     953        }
     954        // Remember first selected item definition:
     955        const QString strDefinition = firstSelectedItem()->definition();
     956        // Rebuild tree for main root:
     957        buildTreeForMainRoot();
     958        updateNavigationItemList();
     959        updateLayout();
     960        // Restore selection:
     961        setSelectedItem(strDefinition);
     962
    940963        delete pWizard;
    941964    }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVM.cpp

    r83670 r83676  
    2323
    2424/* COM includes: */
    25 #include "CCloudMachine.h"
    2625#include "CProgress.h"
    2726
     
    6968bool UIWizardAddCloudVM::addCloudVMs()
    7069{
    71     /* Acquire prepared client and description: */
     70    /* Prepare result: */
     71    bool fResult = false;
     72
     73    /* Acquire prepared client: */
    7274    CCloudClient comClient = client();
    73     AssertReturn(comClient.isNotNull(), false);
     75    AssertReturn(comClient.isNotNull(), fResult);
    7476
    7577    /* For each cloud instance name we have: */
    7678    foreach (const QString &strInstanceName, field("instanceIds").toStringList())
    7779    {
     80        /* Initiate cloud VM add procedure: */
    7881        CCloudMachine comMachine;
    79 
    80         /* Initiate cloud VM add procedure: */
    8182        CProgress comProgress = comClient.AddCloudMachine(strInstanceName, comMachine);
    82         RT_NOREF(comMachine);
     83        /* Check for immediate errors: */
    8384        if (!comClient.isOk())
    8485        {
    8586            msgCenter().cannotCreateCloudMachine(comClient, this);
    86             return false;
     87            break;
    8788        }
    88 
    89         /* Show "Add cloud machine" progress: */
    90         msgCenter().showModalProgressDialog(comProgress, tr("Add cloud machine ..."),
    91                                             ":/progress_new_cloud_vm_90px.png", this, 0);
    92         if (comProgress.GetCanceled())
    93             return false;
    94         if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     89        else
    9590        {
    96             msgCenter().cannotCreateCloudMachine(comProgress, this);
    97             return false;
     91            /* Show "Add cloud machine" progress: */
     92            msgCenter().showModalProgressDialog(comProgress, tr("Add cloud machine ..."),
     93                                                ":/progress_new_cloud_vm_90px.png", this, 0);
     94            /* Check for canceled progress: */
     95            if (comProgress.GetCanceled())
     96                break;
     97            else
     98            {
     99                /* Check for progress errors: */
     100                if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     101                {
     102                    msgCenter().cannotCreateCloudMachine(comProgress, this);
     103                    break;
     104                }
     105                else
     106                {
     107                    /* Check whether VM really added: */
     108                    if (comMachine.isNotNull())
     109                    {
     110                        m_machines << comMachine;
     111                        fResult = true;
     112                    }
     113                }
     114            }
    98115        }
    99116    }
    100117
    101     /* Success by default: */
    102     return true;
     118    /* Return result: */
     119    return fResult;
    103120}
    104121
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/addcloudvm/UIWizardAddCloudVM.h

    r83653 r83676  
    2828#include "COMEnums.h"
    2929#include "CCloudClient.h"
     30#include "CCloudMachine.h"
    3031
    3132/** Add Cloud VM wizard. */
     
    5758    virtual void prepare() /* override */;
    5859
    59     /** Defines Cloud @a comClient object. */
     60    /** Defines Cloud @a comClient object wrapper. */
    6061    void setClient(const CCloudClient &comClient) { m_comClient = comClient; }
    61     /** Returns Cloud Client object. */
     62    /** Returns Cloud Client object wrapper. */
    6263    CCloudClient client() const { return m_comClient; }
     64
     65    /** Returns Cloud Machine object wrapper list. */
     66    QList<CCloudMachine> machines() const { return m_machines; }
    6367
    6468    /** Adds cloud VMs. */
     
    7478    /** Holds the Cloud Client object wrapper. */
    7579    CCloudClient  m_comClient;
     80
     81    /** Holds the Cloud Machine object wrapper list. */
     82    QList<CCloudMachine>  m_machines;
    7683};
    7784
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