VirtualBox

Changeset 21826 in vbox


Ignore:
Timestamp:
Jul 27, 2009 8:00:42 PM (16 years ago)
Author:
vboxsync
Message:

Main: fix wrong snapshot counts introduced by r50442 (erroneous error message when discarding snapshots)

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/MachineImpl.cpp

    r21823 r21826  
    17301730    *aSnapshotCount = !mData->mFirstSnapshot
    17311731                          ? 0
    1732                           : mData->mFirstSnapshot->getGrandChildrenCount() + 1;
     1732                          : mData->mFirstSnapshot->getAllChildrenCount() + 1;
    17331733
    17341734    return S_OK;
     
    43314331        size_t snapshotCount = 0;
    43324332        if (mData->mFirstSnapshot)
    4333             snapshotCount = mData->mFirstSnapshot->getGrandChildrenCount() + 1;
     4333            snapshotCount = mData->mFirstSnapshot->getAllChildrenCount() + 1;
    43344334        if (snapshotCount)
    43354335            return setError (VBOX_E_INVALID_OBJECT_STATE,
     
    92149214    AutoWriteLock snapshotLock(snapshot);
    92159215
    9216     size_t childrenCount = snapshot->getGrandChildrenCount();
     9216    size_t childrenCount = snapshot->getChildrenCount();
    92179217    if (childrenCount > 1)
    92189218        return setError(VBOX_E_INVALID_OBJECT_STATE,
  • trunk/src/VBox/Main/SnapshotImpl.cpp

    r21825 r21826  
    406406}
    407407
    408 ULONG Snapshot::getGrandChildrenCount()
     408ULONG Snapshot::getChildrenCount()
    409409{
    410410    AutoCaller autoCaller(this);
     
    414414    AutoReadLock alock(this);
    415415
     416    return (ULONG)m->llChildren.size();
     417}
     418
     419ULONG Snapshot::getAllChildrenCountImpl()
     420{
     421    AutoCaller autoCaller(this);
     422    AssertComRC(autoCaller.rc());
     423
     424    AutoReadLock alock(this);
    416425    ULONG count = (ULONG)m->llChildren.size();
    417426    for (SnapshotsList::const_iterator it = m->llChildren.begin();
     
    419428         ++it)
    420429    {
    421         count += (*it)->getGrandChildrenCount();
     430        count += (*it)->getAllChildrenCountImpl();
    422431    }
    423432
    424433    return count;
     434}
     435
     436ULONG Snapshot::getAllChildrenCount()
     437{
     438    AutoCaller autoCaller(this);
     439    AssertComRC(autoCaller.rc());
     440
     441    AutoReadLock chLock(m->pMachine->snapshotsTreeLockHandle());
     442    return getAllChildrenCountImpl();
    425443}
    426444
  • trunk/src/VBox/Main/include/SnapshotImpl.h

    r21823 r21826  
    100100    }
    101101
    102     ULONG getGrandChildrenCount();
     102    ULONG getChildrenCount();
     103    ULONG getAllChildrenCount();
     104    ULONG getAllChildrenCountImpl();
    103105
    104106    ComPtr<SnapshotMachine> getSnapshotMachine();
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