VirtualBox

Changeset 86678 in vbox for trunk


Ignore:
Timestamp:
Oct 22, 2020 7:06:17 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: Make sure we don't already have cloud VM with certain id while registering it.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
Files:
2 edited

Legend:

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

    r86665 r86678  
    757757        return;
    758758
     759    /* Compose corresponding group path: */
     760    const QString strGroup = QString("/%1/%2").arg(strProviderShortName, strProfileName);
     761    /* Make sure there is no VM with such ID already: */
     762    QUuid uId;
     763    if (!cloudMachineId(comMachine, uId))
     764        return;
     765    if (checkIfNodeContainChildWithId(pProfileNode, uId))
     766        return;
    759767    /* Add new machine-item: */
    760     const QString strGroup = QString("/%1/%2").arg(strProviderShortName, strProfileName);
    761768    addCloudMachineIntoTheTree(strGroup, comMachine, true /* make it visible? */);
    762769
     
    774781        return;
    775782
    776     /* Add new machine-items: */
     783    /* Compose corresponding group path: */
    777784    const QString strGroup = QString("/%1/%2").arg(strProviderShortName, strProfileName);
    778785    foreach (const CCloudMachine &comMachine, machines)
     786    {
     787        /* Make sure there is no VM with such ID already: */
     788        QUuid uId;
     789        if (!cloudMachineId(comMachine, uId))
     790            continue;
     791        if (checkIfNodeContainChildWithId(pProfileNode, uId))
     792            continue;
     793        /* Add new machine-item: */
    779794        addCloudMachineIntoTheTree(strGroup, comMachine, false /* make it visible? */);
     795    }
    780796
    781797    /* Delete fake node if present: */
     
    14961512}
    14971513
     1514bool UIChooserAbstractModel::checkIfNodeContainChildWithId(UIChooserNode *pParentNode, const QUuid &uId) const
     1515{
     1516    /* Check parent-node type: */
     1517    AssertPtrReturn(pParentNode, false);
     1518    switch (pParentNode->type())
     1519    {
     1520        case UIChooserNodeType_Machine:
     1521        {
     1522            /* Check if pParentNode has the passed uId itself: */
     1523            UIChooserNodeMachine *pMachineNode = pParentNode->toMachineNode();
     1524            AssertPtrReturn(pMachineNode, false);
     1525            if (pMachineNode->id() == uId)
     1526                return true;
     1527            break;
     1528        }
     1529        case UIChooserNodeType_Group:
     1530        {
     1531            /* Recursively iterate through children: */
     1532            foreach (UIChooserNode *pChildNode, pParentNode->nodes())
     1533                if (checkIfNodeContainChildWithId(pChildNode, uId))
     1534                    return true;
     1535            break;
     1536        }
     1537        default:
     1538            break;
     1539    }
     1540
     1541    /* False by default: */
     1542    return false;
     1543}
     1544
    14981545void UIChooserAbstractModel::saveGroupSettings()
    14991546{
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h

    r86665 r86678  
    288288        /** Gathers a list of possible group node names for machine nodes listed in @a exceptions, starting from @a pCurrentNode. */
    289289        QStringList gatherPossibleGroupNodeNames(UIChooserNode *pCurrentNode, QList<UIChooserNode*> exceptions) const;
     290
     291        /** Returns whether passed @a pParentNode contains child node with passed @a uId. */
     292        bool checkIfNodeContainChildWithId(UIChooserNode *pParentNode, const QUuid &uId) const;
    290293    /** @} */
    291294
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