VirtualBox

Changeset 42889 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 20, 2012 5:44:10 PM (12 years ago)
Author:
vboxsync
Message:

Main/Snapshot: stop abusing the mPeer field, because this triggers various settings related problems when loading settings and the like. A SnapshotMachine is not a SessionMachine, and this they shouldn't be treated the same.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/MachineImpl.h

    r42841 r42889  
    948948#endif /* VBOX_WITH_RESOURCE_USAGE_API */
    949949
    950     Machine* const          mPeer;
     950    Machine * const         mPeer;
    951951
    952952    VirtualBox * const      mParent;
     
    12741274
    12751275    Guid mSnapshotId;
     1276    /** This field replaces mPeer for SessionMachine instances, as having
     1277     * a peer reference is plain meaningless and causes many subtle problems
     1278     * with saving settings and the like. */
     1279    Machine * const mMachine;
    12761280
    12771281    friend class Snapshot;
  • trunk/src/VBox/Main/src-server/SnapshotImpl.cpp

    r42123 r42889  
    915915////////////////////////////////////////////////////////////////////////////////
    916916
    917 DEFINE_EMPTY_CTOR_DTOR(SnapshotMachine)
     917SnapshotMachine::SnapshotMachine()
     918    : mMachine(NULL)
     919{}
     920
     921SnapshotMachine::~SnapshotMachine()
     922{}
    918923
    919924HRESULT SnapshotMachine::FinalConstruct()
     
    959964
    960965    mSnapshotId = aSnapshotId;
    961 
     966    ComObjPtr<Machine> pMachine = aSessionMachine->mPeer;
     967
     968    /* mPeer stays NULL */
    962969    /* memorize the primary Machine instance (i.e. not SessionMachine!) */
    963     unconst(mPeer) = aSessionMachine->mPeer;
     970    unconst(mMachine) = pMachine;
    964971    /* share the parent pointer */
    965     unconst(mParent) = mPeer->mParent;
     972    unconst(mParent) = pMachine->mParent;
    966973
    967974    /* take the pointer to Data to share */
    968     mData.share(mPeer->mData);
     975    mData.share(pMachine->mData);
    969976
    970977    /* take the pointer to UserData to share (our UserData must always be the
    971978     * same as Machine's data) */
    972     mUserData.share(mPeer->mUserData);
     979    mUserData.share(pMachine->mUserData);
    973980    /* make a private copy of all other data (recent changes from SessionMachine) */
    974981    mHWData.attachCopy(aSessionMachine->mHWData);
     
    10261033
    10271034    unconst(mBIOSSettings).createObject();
    1028     mBIOSSettings->initCopy(this, mPeer->mBIOSSettings);
     1035    mBIOSSettings->initCopy(this, pMachine->mBIOSSettings);
    10291036
    10301037    unconst(mVRDEServer).createObject();
    1031     mVRDEServer->initCopy(this, mPeer->mVRDEServer);
     1038    mVRDEServer->initCopy(this, pMachine->mVRDEServer);
    10321039
    10331040    unconst(mAudioAdapter).createObject();
    1034     mAudioAdapter->initCopy(this, mPeer->mAudioAdapter);
     1041    mAudioAdapter->initCopy(this, pMachine->mAudioAdapter);
    10351042
    10361043    unconst(mUSBController).createObject();
    1037     mUSBController->initCopy(this, mPeer->mUSBController);
    1038 
    1039     mNetworkAdapters.resize(mPeer->mNetworkAdapters.size());
     1044    mUSBController->initCopy(this, pMachine->mUSBController);
     1045
     1046    mNetworkAdapters.resize(pMachine->mNetworkAdapters.size());
    10401047    for (ULONG slot = 0; slot < mNetworkAdapters.size(); slot++)
    10411048    {
    10421049        unconst(mNetworkAdapters[slot]).createObject();
    1043         mNetworkAdapters[slot]->initCopy(this, mPeer->mNetworkAdapters[slot]);
     1050        mNetworkAdapters[slot]->initCopy(this, pMachine->mNetworkAdapters[slot]);
    10441051    }
    10451052
     
    10471054    {
    10481055        unconst(mSerialPorts[slot]).createObject();
    1049         mSerialPorts[slot]->initCopy(this, mPeer->mSerialPorts[slot]);
     1056        mSerialPorts[slot]->initCopy(this, pMachine->mSerialPorts[slot]);
    10501057    }
    10511058
     
    10531060    {
    10541061        unconst(mParallelPorts[slot]).createObject();
    1055         mParallelPorts[slot]->initCopy(this, mPeer->mParallelPorts[slot]);
     1062        mParallelPorts[slot]->initCopy(this, pMachine->mParallelPorts[slot]);
    10561063    }
    10571064
    10581065    unconst(mBandwidthControl).createObject();
    1059     mBandwidthControl->initCopy(this, mPeer->mBandwidthControl);
     1066    mBandwidthControl->initCopy(this, pMachine->mBandwidthControl);
    10601067
    10611068    /* Confirm a successful initialization when it's the case */
     
    10991106    mSnapshotId = aSnapshotId;
    11001107
    1101     /* memorize the primary Machine instance */
    1102     unconst(mPeer) = aMachine;
     1108    /* mPeer stays NULL */
     1109    /* memorize the primary Machine instance (i.e. not SessionMachine!) */
     1110    unconst(mMachine) = aMachine;
    11031111    /* share the parent pointer */
    1104     unconst(mParent) = mPeer->mParent;
     1112    unconst(mParent) = aMachine->mParent;
    11051113
    11061114    /* take the pointer to Data to share */
    1107     mData.share(mPeer->mData);
     1115    mData.share(aMachine->mData);
    11081116    /*
    11091117     *  take the pointer to UserData to share
    11101118     *  (our UserData must always be the same as Machine's data)
    11111119     */
    1112     mUserData.share(mPeer->mUserData);
     1120    mUserData.share(aMachine->mUserData);
    11131121    /* allocate private copies of all other data (will be loaded from settings) */
    11141122    mHWData.allocate();
     
    11951203    mData.free();
    11961204
     1205    unconst(mMachine) = NULL;
    11971206    unconst(mParent) = NULL;
    11981207    unconst(mPeer) = NULL;
     
    12031212/**
    12041213 *  Overrides VirtualBoxBase::lockHandle() in order to share the lock handle
    1205  *  with the primary Machine instance (mPeer).
     1214 *  with the primary Machine instance (mMachine) if it exists.
    12061215 */
    12071216RWLockHandle *SnapshotMachine::lockHandle() const
    12081217{
    1209     AssertReturn(mPeer != NULL, NULL);
    1210     return mPeer->lockHandle();
     1218    AssertReturn(mMachine != NULL, NULL);
     1219    return mMachine->lockHandle();
    12111220}
    12121221
     
    12331242     * modification of the current state flag, cause this snapshot data isn't
    12341243     * related to the current state. */
    1235     mPeer->setModified(Machine::IsModified_Snapshots, false /* fAllowStateModification */);
    1236     HRESULT rc = mPeer->saveSettings(&fNeedsGlobalSaveSettings,
    1237                                      SaveS_Force);        // we know we need saving, no need to check
     1244    mMachine->setModified(Machine::IsModified_Snapshots, false /* fAllowStateModification */);
     1245    HRESULT rc = mMachine->saveSettings(&fNeedsGlobalSaveSettings,
     1246                                        SaveS_Force);        // we know we need saving, no need to check
    12381247    mlock.release();
    12391248
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