Changeset 94787 in vbox for trunk/src/VBox/Main/src-server/MediumImpl.cpp
- Timestamp:
- May 2, 2022 7:47:56 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 151178
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r94600 r94787 1389 1389 llParentsTodo.push_back(NULL); 1390 1390 1391 while ( llSettingsTodo.size() > 0)1391 while (!llSettingsTodo.empty()) 1392 1392 { 1393 1393 const settings::Medium *current = llSettingsTodo.front(); … … 1580 1580 AutoWriteLock treeLock(pVirtualBox->i_getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 1581 1581 1582 MediaList llMediaTodo; 1582 /* Must use a list without refcounting help since "this" might already have 1583 * reached 0, and then the refcount must not be increased again since it 1584 * would otherwise trigger a double free. For all other list entries this 1585 * needs manual refcount updating, to make sure the refcount for children 1586 * does not drop to 0 too early. */ 1587 std::list<Medium *> llMediaTodo; 1583 1588 llMediaTodo.push_back(this); 1584 1589 1585 1590 while (!llMediaTodo.empty()) 1586 1591 { 1587 /* This also guarantees that the refcount doesn't actually drop to 0 1588 * again while the uninit is already ongoing. */ 1589 ComObjPtr<Medium> pMedium = llMediaTodo.front(); 1592 Medium *pMedium = llMediaTodo.front(); 1590 1593 llMediaTodo.pop_front(); 1591 1594 … … 1593 1596 AutoUninitSpan autoUninitSpan(pMedium); 1594 1597 if (autoUninitSpan.uninitDone()) 1598 { 1599 if (pMedium != this) 1600 pMedium->Release(); 1595 1601 continue; 1602 } 1596 1603 1597 1604 Assert(!pMedium->isWriteLockOnCurrentThread()); … … 1604 1611 pMedium->m->formatObj.setNull(); 1605 1612 1606 if ( m->state == MediumState_Deleting)1613 if (pMedium->m->state == MediumState_Deleting) 1607 1614 { 1608 1615 /* This medium has been already deleted (directly or as part of a 1609 1616 * merge). Reparenting has already been done. */ 1610 Assert(m->pParent.isNull()); 1611 Assert(m->llChildren.empty()); 1617 Assert(pMedium->m->pParent.isNull()); 1618 Assert(pMedium->m->llChildren.empty()); 1619 if (pMedium != this) 1620 pMedium->Release(); 1612 1621 continue; 1613 1622 } … … 1626 1635 Medium *pChild = *it; 1627 1636 pChild->m->pParent.setNull(); 1637 pChild->AddRef(); 1628 1638 llMediaTodo.push_back(pChild); 1629 1639 } … … 1633 1643 1634 1644 unconst(pMedium->m->pVirtualBox) = NULL; 1645 1646 if (pMedium != this) 1647 pMedium->Release(); 1635 1648 1636 1649 autoUninitSpan.setSucceeded(); … … 4277 4290 bool fAdd = false; 4278 4291 4279 while ( llMediaTodo.size() > 0)4292 while (!llMediaTodo.empty()) 4280 4293 { 4281 4294 ComObjPtr<Medium> pMedium = llMediaTodo.front(); … … 4345 4358 bool fRemove = false; 4346 4359 4347 while ( llMediaTodo.size() > 0)4360 while (!llMediaTodo.empty()) 4348 4361 { 4349 4362 ComObjPtr<Medium> pMedium = llMediaTodo.front(); … … 4654 4667 llMediaTodo.push_back(this); 4655 4668 4656 while ( llMediaTodo.size() > 0)4669 while (!llMediaTodo.empty()) 4657 4670 { 4658 4671 const Medium *pMedium = llMediaTodo.front(); … … 5019 5032 llSettingsTodo.push_back(&data); 5020 5033 5021 while ( llMediaTodo.size() > 0)5034 while (!llMediaTodo.empty()) 5022 5035 { 5023 5036 ComObjPtr<Medium> pMedium = llMediaTodo.front();
Note:
See TracChangeset
for help on using the changeset viewer.