VirtualBox

Changeset 86803 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 3, 2020 8:10:42 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: Assertion fix for a case when where is no provider or profile to the moment refresh task is done; Besides that, we should unregister task in any case.

File:
1 edited

Legend:

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

    r86802 r86803  
    862862        return;
    863863
    864     /* Search for profile node: */
    865     UIChooserNode *pProfileNode = searchProfileNode(guiCloudProfileKey.m_strProviderShortName,
    866                                                     guiCloudProfileKey.m_strProfileName);
    867     if (!pProfileNode)
    868         return;
    869 
    870     /* Compose old set of machine IDs: */
    871     QSet<QUuid> oldIDs;
    872     foreach (UIChooserNode *pNode, pProfileNode->nodes(UIChooserNodeType_Machine))
    873     {
    874         AssertPtrReturnVoid(pNode);
    875         UIChooserNodeMachine *pNodeMachine = pNode->toMachineNode();
    876         AssertPtrReturnVoid(pNodeMachine);
    877         if (pNodeMachine->cacheType() != UIVirtualMachineItemType_CloudReal)
    878             continue;
    879         oldIDs << pNodeMachine->id();
    880     }
    881     /* Compose new set of machine IDs and map of machines: */
    882     QSet<QUuid> newIDs;
    883     QMap<QUuid, CCloudMachine> newMachines;
    884     foreach (const CCloudMachine &comMachine, machines)
    885     {
    886         QUuid uId;
    887         AssertReturnVoid(cloudMachineId(comMachine, uId));
    888         newMachines[uId] = comMachine;
    889         newIDs << uId;
    890     }
    891 
    892     /* Calculate set of unregistered/registered IDs: */
    893     const QSet<QUuid> unregisteredIDs = oldIDs - newIDs;
    894     const QSet<QUuid> registeredIDs = newIDs - oldIDs;
    895     QVector<CCloudMachine> registeredMachines;
    896     foreach (const QUuid &uId, registeredIDs)
    897         registeredMachines << newMachines.value(uId);
    898 
    899     /* Remove unregistered cloud VM nodes: */
    900     if (!unregisteredIDs.isEmpty())
    901         sltCloudMachinesUnregistered(guiCloudProfileKey.m_strProviderShortName,
    902                                      guiCloudProfileKey.m_strProfileName,
    903                                      unregisteredIDs.toList());
    904     /* Add registered cloud VM nodes: */
    905     if (!registeredMachines.isEmpty())
    906         sltCloudMachinesRegistered(guiCloudProfileKey.m_strProviderShortName,
    907                                    guiCloudProfileKey.m_strProfileName,
    908                                    registeredMachines);
    909     /* If we changed nothing and have nothing currently: */
    910     if (unregisteredIDs.isEmpty() && newIDs.isEmpty())
    911     {
    912         /* We should update at least fake cloud machine node: */
    913         UIChooserNode *pFakeNode = searchFakeNode(pProfileNode);
    914         AssertPtrReturnVoid(pFakeNode);
    915         pFakeNode->toMachineNode()->cache()->toCloud()->setFakeCloudItemState(UIFakeCloudVirtualMachineItemState_Done);
    916         pFakeNode->item()->updateItem();
     864    /* Search for provider node separately, it can be removed already: */
     865    UIChooserNode *pProviderNode = searchProviderNode(guiCloudProfileKey.m_strProviderShortName);
     866    if (pProviderNode)
     867    {
     868        /* Search for profile node separately, it can be hidden at all: */
     869        UIChooserNode *pProfileNode = searchProfileNode(pProviderNode, guiCloudProfileKey.m_strProfileName);
     870        if (pProfileNode)
     871        {
     872            /* Compose old set of machine IDs: */
     873            QSet<QUuid> oldIDs;
     874            foreach (UIChooserNode *pNode, pProfileNode->nodes(UIChooserNodeType_Machine))
     875            {
     876                AssertPtrReturnVoid(pNode);
     877                UIChooserNodeMachine *pNodeMachine = pNode->toMachineNode();
     878                AssertPtrReturnVoid(pNodeMachine);
     879                if (pNodeMachine->cacheType() != UIVirtualMachineItemType_CloudReal)
     880                    continue;
     881                oldIDs << pNodeMachine->id();
     882            }
     883            /* Compose new set of machine IDs and map of machines: */
     884            QSet<QUuid> newIDs;
     885            QMap<QUuid, CCloudMachine> newMachines;
     886            foreach (const CCloudMachine &comMachine, machines)
     887            {
     888                QUuid uId;
     889                AssertReturnVoid(cloudMachineId(comMachine, uId));
     890                newMachines[uId] = comMachine;
     891                newIDs << uId;
     892            }
     893
     894            /* Calculate set of unregistered/registered IDs: */
     895            const QSet<QUuid> unregisteredIDs = oldIDs - newIDs;
     896            const QSet<QUuid> registeredIDs = newIDs - oldIDs;
     897            QVector<CCloudMachine> registeredMachines;
     898            foreach (const QUuid &uId, registeredIDs)
     899                registeredMachines << newMachines.value(uId);
     900
     901            /* Remove unregistered cloud VM nodes: */
     902            if (!unregisteredIDs.isEmpty())
     903                sltCloudMachinesUnregistered(guiCloudProfileKey.m_strProviderShortName,
     904                                             guiCloudProfileKey.m_strProfileName,
     905                                             unregisteredIDs.toList());
     906            /* Add registered cloud VM nodes: */
     907            if (!registeredMachines.isEmpty())
     908                sltCloudMachinesRegistered(guiCloudProfileKey.m_strProviderShortName,
     909                                           guiCloudProfileKey.m_strProfileName,
     910                                           registeredMachines);
     911            /* If we changed nothing and have nothing currently: */
     912            if (unregisteredIDs.isEmpty() && newIDs.isEmpty())
     913            {
     914                /* We should update at least fake cloud machine node: */
     915                UIChooserNode *pFakeNode = searchFakeNode(pProfileNode);
     916                AssertPtrReturnVoid(pFakeNode);
     917                pFakeNode->toMachineNode()->cache()->toCloud()->setFakeCloudItemState(UIFakeCloudVirtualMachineItemState_Done);
     918                pFakeNode->item()->updateItem();
     919            }
     920        }
    917921    }
    918922
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