Changeset 42889 in vbox for trunk/src/VBox
- Timestamp:
- Aug 20, 2012 5:44:10 PM (12 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/MachineImpl.h
r42841 r42889 948 948 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 949 949 950 Machine * constmPeer;950 Machine * const mPeer; 951 951 952 952 VirtualBox * const mParent; … … 1274 1274 1275 1275 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; 1276 1280 1277 1281 friend class Snapshot; -
trunk/src/VBox/Main/src-server/SnapshotImpl.cpp
r42123 r42889 915 915 //////////////////////////////////////////////////////////////////////////////// 916 916 917 DEFINE_EMPTY_CTOR_DTOR(SnapshotMachine) 917 SnapshotMachine::SnapshotMachine() 918 : mMachine(NULL) 919 {} 920 921 SnapshotMachine::~SnapshotMachine() 922 {} 918 923 919 924 HRESULT SnapshotMachine::FinalConstruct() … … 959 964 960 965 mSnapshotId = aSnapshotId; 961 966 ComObjPtr<Machine> pMachine = aSessionMachine->mPeer; 967 968 /* mPeer stays NULL */ 962 969 /* memorize the primary Machine instance (i.e. not SessionMachine!) */ 963 unconst(m Peer) = aSessionMachine->mPeer;970 unconst(mMachine) = pMachine; 964 971 /* share the parent pointer */ 965 unconst(mParent) = mPeer->mParent;972 unconst(mParent) = pMachine->mParent; 966 973 967 974 /* take the pointer to Data to share */ 968 mData.share( mPeer->mData);975 mData.share(pMachine->mData); 969 976 970 977 /* take the pointer to UserData to share (our UserData must always be the 971 978 * same as Machine's data) */ 972 mUserData.share( mPeer->mUserData);979 mUserData.share(pMachine->mUserData); 973 980 /* make a private copy of all other data (recent changes from SessionMachine) */ 974 981 mHWData.attachCopy(aSessionMachine->mHWData); … … 1026 1033 1027 1034 unconst(mBIOSSettings).createObject(); 1028 mBIOSSettings->initCopy(this, mPeer->mBIOSSettings);1035 mBIOSSettings->initCopy(this, pMachine->mBIOSSettings); 1029 1036 1030 1037 unconst(mVRDEServer).createObject(); 1031 mVRDEServer->initCopy(this, mPeer->mVRDEServer);1038 mVRDEServer->initCopy(this, pMachine->mVRDEServer); 1032 1039 1033 1040 unconst(mAudioAdapter).createObject(); 1034 mAudioAdapter->initCopy(this, mPeer->mAudioAdapter);1041 mAudioAdapter->initCopy(this, pMachine->mAudioAdapter); 1035 1042 1036 1043 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()); 1040 1047 for (ULONG slot = 0; slot < mNetworkAdapters.size(); slot++) 1041 1048 { 1042 1049 unconst(mNetworkAdapters[slot]).createObject(); 1043 mNetworkAdapters[slot]->initCopy(this, mPeer->mNetworkAdapters[slot]);1050 mNetworkAdapters[slot]->initCopy(this, pMachine->mNetworkAdapters[slot]); 1044 1051 } 1045 1052 … … 1047 1054 { 1048 1055 unconst(mSerialPorts[slot]).createObject(); 1049 mSerialPorts[slot]->initCopy(this, mPeer->mSerialPorts[slot]);1056 mSerialPorts[slot]->initCopy(this, pMachine->mSerialPorts[slot]); 1050 1057 } 1051 1058 … … 1053 1060 { 1054 1061 unconst(mParallelPorts[slot]).createObject(); 1055 mParallelPorts[slot]->initCopy(this, mPeer->mParallelPorts[slot]);1062 mParallelPorts[slot]->initCopy(this, pMachine->mParallelPorts[slot]); 1056 1063 } 1057 1064 1058 1065 unconst(mBandwidthControl).createObject(); 1059 mBandwidthControl->initCopy(this, mPeer->mBandwidthControl);1066 mBandwidthControl->initCopy(this, pMachine->mBandwidthControl); 1060 1067 1061 1068 /* Confirm a successful initialization when it's the case */ … … 1099 1106 mSnapshotId = aSnapshotId; 1100 1107 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; 1103 1111 /* share the parent pointer */ 1104 unconst(mParent) = mPeer->mParent;1112 unconst(mParent) = aMachine->mParent; 1105 1113 1106 1114 /* take the pointer to Data to share */ 1107 mData.share( mPeer->mData);1115 mData.share(aMachine->mData); 1108 1116 /* 1109 1117 * take the pointer to UserData to share 1110 1118 * (our UserData must always be the same as Machine's data) 1111 1119 */ 1112 mUserData.share( mPeer->mUserData);1120 mUserData.share(aMachine->mUserData); 1113 1121 /* allocate private copies of all other data (will be loaded from settings) */ 1114 1122 mHWData.allocate(); … … 1195 1203 mData.free(); 1196 1204 1205 unconst(mMachine) = NULL; 1197 1206 unconst(mParent) = NULL; 1198 1207 unconst(mPeer) = NULL; … … 1203 1212 /** 1204 1213 * Overrides VirtualBoxBase::lockHandle() in order to share the lock handle 1205 * with the primary Machine instance (m Peer).1214 * with the primary Machine instance (mMachine) if it exists. 1206 1215 */ 1207 1216 RWLockHandle *SnapshotMachine::lockHandle() const 1208 1217 { 1209 AssertReturn(m Peer!= NULL, NULL);1210 return m Peer->lockHandle();1218 AssertReturn(mMachine != NULL, NULL); 1219 return mMachine->lockHandle(); 1211 1220 } 1212 1221 … … 1233 1242 * modification of the current state flag, cause this snapshot data isn't 1234 1243 * related to the current state. */ 1235 m Peer->setModified(Machine::IsModified_Snapshots, false /* fAllowStateModification */);1236 HRESULT rc = m Peer->saveSettings(&fNeedsGlobalSaveSettings,1237 SaveS_Force); // we know we need saving, no need to check1244 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 1238 1247 mlock.release(); 1239 1248
Note:
See TracChangeset
for help on using the changeset viewer.