VirtualBox

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


Ignore:
Timestamp:
Nov 26, 2013 12:16:23 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Medium Manager: Handle async diff disk creation/removing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r49657 r49658  
    388388    mTabWidget->setTabIcon(FDTab, m_iconFD);
    389389
    390     /* Load mediums: */
     390    /* Repopulate all medium-items: */
    391391    QList<QString> mediumIDs = vboxGlobal().mediumIDs();
    392     QList<QString> loadedMediumIDs;
    393392    prepareToRefresh(mediumIDs.size());
    394     while (!mediumIDs.isEmpty())
    395     {
    396         /* Get first available medium: */
    397         QString strMediumID = mediumIDs.first();
    398         UIMedium medium = vboxGlobal().medium(strMediumID);
    399         /* Make sure medium parent (if any) is already in list: */
    400         while (medium.parentID() != UIMedium::nullID() &&
    401                !loadedMediumIDs.contains(medium.parentID()))
    402         {
    403             medium = medium.parent();
    404             strMediumID = medium.id();
    405         }
    406         /* Insert resulting medium into tree: */
    407         int iItemIndex = mediumIDs.indexOf(strMediumID);
    408         AssertReturnVoid(iItemIndex != -1);
    409         loadedMediumIDs.append(mediumIDs.takeAt(iItemIndex));
     393    foreach (const QString &strMediumID, mediumIDs)
    410394        sltHandleMediumCreated(strMediumID);
    411     }
    412395
    413396    /* Select the first item to be the current one
     
    441424        return;
    442425
    443     /* Prepare medium-item: */
     426    /* Search for corresponding medium-item: */
    444427    UIMediumItem *pMediumItem = 0;
    445428    switch (medium.type())
     
    450433        default: AssertFailed();
    451434    }
    452     AssertPtrReturnVoid(pMediumItem);
     435
     436    /* If medium-item was not found it's time to create it: */
     437    if (!pMediumItem)
     438        return sltHandleMediumCreated(strMediumID);
    453439
    454440    /* Update medium-item: */
     
    11431129        /* Emulate (possible partial) medium-enumeration: */
    11441130        QList<QString> mediumIDs = vboxGlobal().mediumIDs();
    1145         QList<QString> loadedMediumIDs;
    11461131        prepareToRefresh(mediumIDs.size());
    1147         while (!mediumIDs.isEmpty())
    1148         {
    1149             /* Get first available medium: */
    1150             QString strMediumID = mediumIDs.first();
    1151             UIMedium medium = vboxGlobal().medium(strMediumID);
    1152             /* Make sure medium parent (if any) is already in list: */
    1153             while (medium.parentID() != UIMedium::nullID() &&
    1154                    !loadedMediumIDs.contains(medium.parentID()))
    1155             {
    1156                 medium = medium.parent();
    1157                 strMediumID = medium.id();
    1158             }
    1159             /* Insert resulting medium into tree: */
    1160             int iItemIndex = mediumIDs.indexOf(strMediumID);
    1161             AssertReturnVoid(iItemIndex != -1);
    1162             loadedMediumIDs.append(mediumIDs.takeAt(iItemIndex));
     1132        foreach (const QString &strMediumID, mediumIDs)
     1133        {
     1134            /* Get corresponding medium: */
     1135            const UIMedium medium = vboxGlobal().medium(strMediumID);
     1136            /* Create corresponding medium-item: */
    11631137            sltHandleMediumCreated(strMediumID);
    11641138            /* Advance progress-bar only for created mediums: */
     
    15121486    AssertReturn(!medium.medium().isNull(), 0);
    15131487
    1514     /* Prepare medium-item: */
    1515     UIMediumItem *pMediumItem = 0;
    1516 
    1517     /* First try to create item under corresponding parent: */
    1518     if (medium.parentID() != UIMedium::nullID())
    1519         if (UIMediumItem *pRoot = searchItem(pTree, CheckIfSuitableByID(medium.parentID())))
    1520             pMediumItem = new UIMediumItem(medium, pRoot);
    1521     /* Else just create item as top-level one: */
     1488    /* Search for medium-item: */
     1489    UIMediumItem *pMediumItem = searchItem(pTree, CheckIfSuitableByID(medium.id()));
     1490
     1491    /* If medium-item do not exists: */
    15221492    if (!pMediumItem)
    1523         pMediumItem = new UIMediumItem(medium, pTree);
    1524 
    1525     /* Return created item: */
     1493    {
     1494        /* If medium have a parent: */
     1495        if (medium.parentID() != UIMedium::nullID())
     1496        {
     1497            /* Try to find parent medium-item: */
     1498            UIMediumItem *pParentMediumItem = searchItem(pTree, CheckIfSuitableByID(medium.parentID()));
     1499            /* If parent medium-item was not found: */
     1500            if (!pParentMediumItem)
     1501            {
     1502                /* Make sure such corresponding parent medium is already cached! */
     1503                UIMedium parentMedium = vboxGlobal().medium(medium.parentID());
     1504                if (parentMedium.isNull())
     1505                    AssertMsgFailed(("Parent medium with ID={%s} was not found!\n", medium.parentID().toAscii().constData()));
     1506                /* Try to create parent medium-item: */
     1507                else
     1508                    pParentMediumItem = createHardDiskItem(pTree, parentMedium);
     1509            }
     1510            /* If parent medium-item was found: */
     1511            if (pParentMediumItem)
     1512                pMediumItem = new UIMediumItem(medium, pParentMediumItem);
     1513        }
     1514        /* Else just create item as top-level one: */
     1515        if (!pMediumItem)
     1516            pMediumItem = new UIMediumItem(medium, pTree);
     1517    }
     1518
     1519    /* Return medium-item: */
    15261520    return pMediumItem;
    15271521}
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