Changeset 26167 in vbox for trunk/src/VBox
- Timestamp:
- Feb 2, 2010 7:59:09 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 57181
- Location:
- trunk/src/VBox/Main
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/AudioAdapterImpl.cpp
r26156 r26167 205 205 mData.backup(); 206 206 mData->mEnabled = aEnabled; 207 208 alock.release(); 209 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking 210 mParent->setModified(Machine::IsModified_AudioAdapter); 207 211 } 208 212 … … 279 283 mData.backup(); 280 284 mData->mAudioDriver = aAudioDriver; 285 286 alock.release(); 287 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking 288 mParent->setModified(Machine::IsModified_AudioAdapter); 281 289 break; 282 290 } … … 330 338 case AudioControllerType_AC97: 331 339 case AudioControllerType_SB16: 340 { 332 341 mData.backup(); 333 342 mData->mAudioController = aAudioController; 343 344 alock.release(); 345 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking 346 mParent->setModified(Machine::IsModified_AudioAdapter); 334 347 break; 348 } 335 349 336 350 default: 337 {338 351 AssertMsgFailed (("Wrong audio controller type %d\n", 339 352 aAudioController)); 340 353 rc = E_FAIL; 341 }342 354 } 343 355 } … … 414 426 } 415 427 416 bool AudioAdapter::isModified()417 {418 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);419 return mData.isBackedUp();420 }421 422 428 /** 423 429 * @note Locks this object for writing. -
trunk/src/VBox/Main/BIOSSettingsImpl.cpp
r26156 r26167 213 213 m->bd->fLogoFadeIn = enable; 214 214 215 alock.release(); 216 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking 217 m->pMachine->setModified(Machine::IsModified_BIOS); 218 215 219 return S_OK; 216 220 } … … 245 249 m->bd->fLogoFadeOut = enable; 246 250 251 alock.release(); 252 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking 253 m->pMachine->setModified(Machine::IsModified_BIOS); 254 247 255 return S_OK; 248 256 } … … 276 284 m->bd.backup(); 277 285 m->bd->ulLogoDisplayTime = displayTime; 286 287 alock.release(); 288 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking 289 m->pMachine->setModified(Machine::IsModified_BIOS); 278 290 279 291 return S_OK; … … 312 324 m->bd->strLogoImagePath = imagePath; 313 325 326 alock.release(); 327 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking 328 m->pMachine->setModified(Machine::IsModified_BIOS); 329 314 330 return S_OK; 315 331 } … … 343 359 m->bd->biosBootMenuMode = bootMenuMode; 344 360 361 alock.release(); 362 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking 363 m->pMachine->setModified(Machine::IsModified_BIOS); 364 345 365 return S_OK; 346 366 } … … 375 395 m->bd->fACPIEnabled = enable; 376 396 397 alock.release(); 398 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking 399 m->pMachine->setModified(Machine::IsModified_BIOS); 400 377 401 return S_OK; 378 402 } … … 407 431 m->bd->fIOAPICEnabled = enable; 408 432 433 alock.release(); 434 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking 435 m->pMachine->setModified(Machine::IsModified_BIOS); 436 409 437 return S_OK; 410 438 } … … 439 467 m->bd->fPXEDebugEnabled = enable; 440 468 469 alock.release(); 470 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking 471 m->pMachine->setModified(Machine::IsModified_BIOS); 472 441 473 return S_OK; 442 474 } … … 470 502 m->bd.backup(); 471 503 m->bd->llTimeOffset = offset; 504 505 alock.release(); 506 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking 507 m->pMachine->setModified(Machine::IsModified_BIOS); 472 508 473 509 return S_OK; … … 519 555 520 556 return S_OK; 521 }522 523 bool BIOSSettings::isModified()524 {525 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);526 return m->bd.isBackedUp();527 557 } 528 558 -
trunk/src/VBox/Main/MachineImpl.cpp
r26156 r26167 408 408 unconst(mParent) = aParent; 409 409 410 m_flModifications = 0; 411 410 412 /* allocate the essential machine data structure (the rest will be 411 413 * allocated later by initDataAndChildObjects() */ … … 413 415 414 416 mData->m_pMachineConfigFile = NULL; 417 m_flModifications = 0; 415 418 416 419 /* memorize the config file name (as provided) */ … … 681 684 alock.leave(); 682 685 683 if (isModified()) 686 // has machine been modified? 687 if (m_flModifications) 684 688 { 685 689 LogWarningThisFunc(("Discarding unsaved settings changes!\n")); 686 rollback 690 rollback(false /* aNotify */); 687 691 } 688 692 … … 828 832 if (FAILED(rc)) return rc; 829 833 834 setModified(IsModified_MachineData); 830 835 mUserData.backup(); 831 836 mUserData->mName = aName; … … 858 863 if (FAILED(rc)) return rc; 859 864 865 setModified(IsModified_MachineData); 860 866 mUserData.backup(); 861 867 mUserData->mDescription = aDescription; … … 916 922 if (FAILED(rc)) return rc; 917 923 924 setModified(IsModified_MachineData); 918 925 mUserData.backup(); 919 926 mUserData->mOSTypeId = osTypeId; … … 946 953 if (FAILED(rc)) return rc; 947 954 955 setModified(IsModified_MachineData); 948 956 mHWData.backup(); 949 957 mHWData->mFirmwareType = aFirmwareType; … … 984 992 if (FAILED(rc)) return rc; 985 993 994 setModified(IsModified_MachineData); 986 995 mHWData.backup(); 987 996 mHWData->mHWVersion = hwVersion; … … 1021 1030 if (FAILED(rc)) return rc; 1022 1031 1032 setModified(IsModified_MachineData); 1023 1033 mHWData.backup(); 1024 1034 if (hardwareUUID == mData->mUuid) … … 1063 1073 if (FAILED(rc)) return rc; 1064 1074 1075 setModified(IsModified_MachineData); 1065 1076 mHWData.backup(); 1066 1077 mHWData->mMemorySize = memorySize; … … 1114 1125 if (FAILED(rc)) return rc; 1115 1126 1127 setModified(IsModified_MachineData); 1116 1128 mHWData.backup(); 1117 1129 mHWData->mCPUCount = CPUCount; … … 1151 1163 if (enabled) 1152 1164 { 1165 setModified(IsModified_MachineData); 1153 1166 mHWData.backup(); 1154 1167 … … 1182 1195 tr("CPU hotplugging can't be disabled because the maximum number of CPUs is not equal to the amount of CPUs attached\n")); 1183 1196 1197 setModified(IsModified_MachineData); 1184 1198 mHWData.backup(); 1185 1199 } … … 1223 1237 if (FAILED(rc)) return rc; 1224 1238 1239 setModified(IsModified_MachineData); 1225 1240 mHWData.backup(); 1226 1241 mHWData->mVRAMSize = memorySize; … … 1262 1277 if (FAILED(rc)) return rc; 1263 1278 1279 setModified(IsModified_MachineData); 1264 1280 mHWData.backup(); 1265 1281 mHWData->mMemoryBalloonSize = memoryBalloonSize; … … 1295 1311 if (FAILED(rc)) return rc; 1296 1312 1313 setModified(IsModified_MachineData); 1297 1314 mHWData.backup(); 1298 1315 mHWData->mStatisticsUpdateInterval = statisticsUpdateInterval; … … 1329 1346 /** @todo check validity! */ 1330 1347 1348 setModified(IsModified_MachineData); 1331 1349 mHWData.backup(); 1332 1350 mHWData->mAccelerate3DEnabled = enable; … … 1363 1381 /** @todo check validity! */ 1364 1382 1383 setModified(IsModified_MachineData); 1365 1384 mHWData.backup(); 1366 1385 mHWData->mAccelerate2DVideoEnabled = enable; … … 1400 1419 if (FAILED(rc)) return rc; 1401 1420 1421 setModified(IsModified_MachineData); 1402 1422 mHWData.backup(); 1403 1423 mHWData->mMonitorCount = monitorCount; … … 1707 1727 if (FAILED(rc)) return rc; 1708 1728 1729 BOOL *pb; 1730 1709 1731 switch(property) 1710 1732 { 1711 case HWVirtExPropertyType_Enabled: 1733 case HWVirtExPropertyType_Enabled: 1734 pb = &mHWData->mHWVirtExEnabled; 1735 break; 1736 1737 case HWVirtExPropertyType_Exclusive: 1738 pb = &mHWData->mHWVirtExExclusive; 1739 break; 1740 1741 case HWVirtExPropertyType_VPID: 1742 pb = &mHWData->mHWVirtExVPIDEnabled; 1743 break; 1744 1745 case HWVirtExPropertyType_NestedPaging: 1746 pb = &mHWData->mHWVirtExNestedPagingEnabled; 1747 break; 1748 1749 default: 1750 return E_INVALIDARG; 1751 } 1752 1753 if (*pb != !!aVal) 1754 { 1755 setModified(IsModified_MachineData); 1712 1756 mHWData.backup(); 1713 mHWData->mHWVirtExEnabled = !!aVal; 1714 break; 1715 1716 case HWVirtExPropertyType_Exclusive: 1717 mHWData.backup(); 1718 mHWData->mHWVirtExExclusive = !!aVal; 1719 break; 1720 1721 case HWVirtExPropertyType_VPID: 1722 mHWData.backup(); 1723 mHWData->mHWVirtExVPIDEnabled = !!aVal; 1724 break; 1725 1726 case HWVirtExPropertyType_NestedPaging: 1727 mHWData.backup(); 1728 mHWData->mHWVirtExNestedPagingEnabled = !!aVal; 1729 break; 1730 1731 default: 1732 return E_INVALIDARG; 1757 *pb = !!aVal; 1733 1758 } 1734 1759 return S_OK; … … 1778 1803 { 1779 1804 /* the default snapshots folder is 'Snapshots' in the machine dir */ 1780 snapshotFolder = Utf8Str ("Snapshots");1805 snapshotFolder = "Snapshots"; 1781 1806 } 1782 1807 else … … 1784 1809 /* the default snapshots folder is {UUID}, for backwards 1785 1810 * compatibility and to resolve conflicts */ 1786 snapshotFolder = Utf8StrFmt 1811 snapshotFolder = Utf8StrFmt("{%RTuuid}", mData->mUuid.raw()); 1787 1812 } 1788 1813 } … … 1794 1819 aSnapshotFolder, vrc); 1795 1820 1821 setModified(IsModified_MachineData); 1796 1822 mUserData.backup(); 1797 1823 mUserData->mSnapshotFolder = aSnapshotFolder; … … 1895 1921 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1896 1922 1897 Auto WriteLock alock(this COMMA_LOCKVAL_SRC_POS);1923 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1898 1924 1899 1925 HRESULT rc = checkStateDependency(MutableStateDep); … … 1906 1932 *aModified = TRUE; 1907 1933 else 1908 *aModified = isModified();1934 *aModified = (m_flModifications != 0); 1909 1935 1910 1936 return S_OK; … … 2109 2135 if (FAILED(rc)) return rc; 2110 2136 2137 setModified(IsModified_MachineData); 2111 2138 mHWData.backup(); 2112 2139 mHWData->mClipboardMode = aClipboardMode; … … 2149 2176 if (FAILED(rc)) return rc; 2150 2177 2151 try 2152 { 2153 mHWData.backup(); 2154 mHWData->mGuestPropertyNotificationPatterns = aPatterns; 2155 } 2156 catch (...) 2157 { 2158 rc = VirtualBox::handleUnexpectedExceptions(RT_SRC_POS); 2159 } 2178 setModified(IsModified_MachineData); 2179 mHWData.backup(); 2180 mHWData->mGuestPropertyNotificationPatterns = aPatterns; 2160 2181 return rc; 2161 2182 } … … 2192 2213 } 2193 2214 2194 STDMETHODIMP 2195 Machine::COMSETTER(TeleporterEnabled)(BOOL aEnabled) 2215 STDMETHODIMP Machine::COMSETTER(TeleporterEnabled)(BOOL aEnabled) 2196 2216 { 2197 2217 AutoCaller autoCaller(this); … … 2215 2235 Global::stringifyMachineState(mData->mMachineState)); 2216 2236 2237 setModified(IsModified_MachineData); 2217 2238 mUserData.backup(); 2218 2239 mUserData->mTeleporterEnabled = aEnabled; … … 2221 2242 } 2222 2243 2223 STDMETHODIMP 2224 Machine::COMGETTER(TeleporterPort)(ULONG *aPort) 2244 STDMETHODIMP Machine::COMGETTER(TeleporterPort)(ULONG *aPort) 2225 2245 { 2226 2246 CheckComArgOutPointerValid(aPort); … … 2236 2256 } 2237 2257 2238 STDMETHODIMP 2239 Machine::COMSETTER(TeleporterPort)(ULONG aPort) 2258 STDMETHODIMP Machine::COMSETTER(TeleporterPort)(ULONG aPort) 2240 2259 { 2241 2260 if (aPort >= _64K) … … 2250 2269 if (FAILED(rc)) return rc; 2251 2270 2271 setModified(IsModified_MachineData); 2252 2272 mUserData.backup(); 2253 2273 mUserData->mTeleporterPort = aPort; … … 2256 2276 } 2257 2277 2258 STDMETHODIMP 2259 Machine::COMGETTER(TeleporterAddress)(BSTR *aAddress) 2278 STDMETHODIMP Machine::COMGETTER(TeleporterAddress)(BSTR *aAddress) 2260 2279 { 2261 2280 CheckComArgOutPointerValid(aAddress); … … 2271 2290 } 2272 2291 2273 STDMETHODIMP 2274 Machine::COMSETTER(TeleporterAddress)(IN_BSTR aAddress) 2292 STDMETHODIMP Machine::COMSETTER(TeleporterAddress)(IN_BSTR aAddress) 2275 2293 { 2276 2294 AutoCaller autoCaller(this); … … 2282 2300 if (FAILED(rc)) return rc; 2283 2301 2302 setModified(IsModified_MachineData); 2284 2303 mUserData.backup(); 2285 2304 mUserData->mTeleporterAddress = aAddress; … … 2288 2307 } 2289 2308 2290 STDMETHODIMP 2291 Machine::COMGETTER(TeleporterPassword)(BSTR *aPassword) 2309 STDMETHODIMP Machine::COMGETTER(TeleporterPassword)(BSTR *aPassword) 2292 2310 { 2293 2311 CheckComArgOutPointerValid(aPassword); … … 2303 2321 } 2304 2322 2305 STDMETHODIMP 2306 Machine::COMSETTER(TeleporterPassword)(IN_BSTR aPassword) 2323 STDMETHODIMP Machine::COMSETTER(TeleporterPassword)(IN_BSTR aPassword) 2307 2324 { 2308 2325 AutoCaller autoCaller(this); … … 2314 2331 if (FAILED(rc)) return rc; 2315 2332 2333 setModified(IsModified_MachineData); 2316 2334 mUserData.backup(); 2317 2335 mUserData->mTeleporterPassword = aPassword; … … 2320 2338 } 2321 2339 2322 STDMETHODIMP 2323 Machine::COMGETTER(RTCUseUTC)(BOOL *aEnabled) 2340 STDMETHODIMP Machine::COMGETTER(RTCUseUTC)(BOOL *aEnabled) 2324 2341 { 2325 2342 CheckComArgOutPointerValid(aEnabled); … … 2335 2352 } 2336 2353 2337 STDMETHODIMP 2338 Machine::COMSETTER(RTCUseUTC)(BOOL aEnabled) 2354 STDMETHODIMP Machine::COMSETTER(RTCUseUTC)(BOOL aEnabled) 2339 2355 { 2340 2356 AutoCaller autoCaller(this); … … 2358 2374 Global::stringifyMachineState(mData->mMachineState)); 2359 2375 2376 setModified(IsModified_MachineData); 2360 2377 mUserData.backup(); 2361 2378 mUserData->mRTCUseUTC = aEnabled; … … 2364 2381 } 2365 2382 2366 2367 // IMachine methods 2368 ///////////////////////////////////////////////////////////////////////////// 2369 2370 STDMETHODIMP Machine::SetBootOrder (ULONG aPosition, DeviceType_T aDevice) 2383 STDMETHODIMP Machine::SetBootOrder(ULONG aPosition, DeviceType_T aDevice) 2371 2384 { 2372 2385 if (aPosition < 1 || aPosition > SchemaDefs::MaxBootPosition) … … 2387 2400 if (FAILED(rc)) return rc; 2388 2401 2402 setModified(IsModified_MachineData); 2389 2403 mHWData.backup(); 2390 2404 mHWData->mBootOrder [aPosition - 1] = aDevice; … … 2823 2837 2824 2838 /* success: finally remember the attachment */ 2839 setModified(IsModified_Storage); 2825 2840 mMediaData.backup(); 2826 2841 mMediaData->mAttachments.push_back(attachment); … … 2901 2916 } 2902 2917 2918 setModified(IsModified_Storage); 2903 2919 mMediaData.backup(); 2904 2920 … … 2955 2971 2956 2972 2973 setModified(IsModified_Storage); 2957 2974 mMediaData.backup(); 2958 2975 … … 3066 3083 if (SUCCEEDED(rc)) 3067 3084 { 3068 3085 setModified(IsModified_Storage); 3069 3086 mMediaData.backup(); 3087 3070 3088 /* The backup operation makes the pAttach reference point to the 3071 3089 * old settings. Re-get the correct reference. */ … … 3514 3532 if (FAILED(rc)) return rc; 3515 3533 3534 setModified(IsModified_SharedFolders); 3516 3535 mHWData.backup(); 3517 3536 mHWData->mSharedFolders.push_back (sharedFolder); … … 3540 3559 if (FAILED(rc)) return rc; 3541 3560 3561 setModified(IsModified_SharedFolders); 3542 3562 mHWData.backup(); 3543 3563 mHWData->mSharedFolders.remove (sharedFolder); … … 3743 3763 else 3744 3764 { 3745 mHWData.backup(); 3765 setModified(IsModified_MachineData); 3766 mHWData.backup(); // @todo r=dj backup in a loop?!? 3767 3746 3768 /* The backup() operation invalidates our iterator, so 3747 3769 * get a new one. */ … … 3750 3772 ++it) 3751 3773 ; 3752 mHWData->mGuestProperties.erase 3774 mHWData->mGuestProperties.erase(it); 3753 3775 } 3754 3776 found = true; … … 3770 3792 { 3771 3793 RTTIMESPEC time; 3794 setModified(IsModified_MachineData); 3772 3795 mHWData.backup(); 3773 3796 property.strName = aName; … … 4008 4031 if (FAILED(rc)) return rc; 4009 4032 4033 setModified(IsModified_Storage); 4010 4034 mStorageControllers.backup(); 4011 4035 mStorageControllers->push_back (ctrl); … … 4092 4116 4093 4117 /* We can remove it now. */ 4118 setModified(IsModified_Storage); 4094 4119 mStorageControllers.backup(); 4095 4120 … … 4409 4434 if (FAILED(rc)) return rc; 4410 4435 4436 setModified(IsModified_MachineData); 4411 4437 mHWData.backup(); 4412 4438 mHWData->mCPUAttached[aCpu] = true; … … 4449 4475 if (FAILED(rc)) return rc; 4450 4476 4477 setModified(IsModified_MachineData); 4451 4478 mHWData.backup(); 4452 4479 mHWData->mCPUAttached[aCpu] = false; … … 4489 4516 // public methods for internal purposes 4490 4517 ///////////////////////////////////////////////////////////////////////////// 4518 4519 /** 4520 * Adds the given IsModified_* flag to the dirty flags of the machine. 4521 * This must be called either during loadSettings or under the machine write lock. 4522 * @param fl 4523 */ 4524 void Machine::setModified(uint32_t fl) 4525 { 4526 m_flModifications |= fl; 4527 } 4491 4528 4492 4529 /** … … 5439 5476 HRESULT rc = S_OK; 5440 5477 5441 /* Ensure the settings are saved. If we are going to be registered and 5442 * isConfigLocked() is FALSE then it means that no config file exists yet, 5443 * so create it by calling saveSettings() too. */ 5444 if ( isModified() 5478 // Ensure the settings are saved. If we are going to be registered and 5479 // no config file exists yet, create it by calling saveSettings() too. 5480 if ( (m_flModifications) 5445 5481 || (argNewRegistered && !mData->m_pMachineConfigFile->fileExists()) 5446 5482 ) … … 6089 6125 mData->mMachineState = MachineState_Saved; 6090 6126 } 6127 6128 // after loading settings, we are no longer different from the XML on disk 6129 m_flModifications = 0; 6091 6130 } 6092 6131 catch (HRESULT err) … … 6659 6698 /* back up mMediaData to let registeredInit() properly rollback on failure 6660 6699 * (= limited accessibility) */ 6700 setModified(IsModified_Storage); 6661 6701 mMediaData.backup(); 6662 6702 mMediaData->mAttachments.push_back(pAttachment); … … 7145 7185 // now spit it all out! 7146 7186 mData->m_pMachineConfigFile->write(mData->m_strConfigFileFull); 7187 7188 // after saving settings, we are no longer different from the XML on disk 7189 m_flModifications = 0; 7147 7190 } 7148 7191 catch (HRESULT err) … … 8216 8259 8217 8260 /** 8218 * @note Locks objects for reading!8219 */8220 bool Machine::isModified()8221 {8222 AutoCaller autoCaller(this);8223 AssertComRCReturn (autoCaller.rc(), false);8224 8225 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);8226 8227 for (ULONG slot = 0; slot < RT_ELEMENTS (mNetworkAdapters); slot ++)8228 if (mNetworkAdapters [slot] && mNetworkAdapters [slot]->isModified())8229 return true;8230 8231 for (ULONG slot = 0; slot < RT_ELEMENTS (mSerialPorts); slot ++)8232 if (mSerialPorts [slot] && mSerialPorts [slot]->isModified())8233 return true;8234 8235 for (ULONG slot = 0; slot < RT_ELEMENTS (mParallelPorts); slot ++)8236 if (mParallelPorts [slot] && mParallelPorts [slot]->isModified())8237 return true;8238 8239 if (!mStorageControllers.isNull())8240 {8241 for (StorageControllerList::const_iterator it =8242 mStorageControllers->begin();8243 it != mStorageControllers->end();8244 ++it)8245 {8246 if ((*it)->isModified())8247 return true;8248 }8249 }8250 8251 return8252 mUserData.isBackedUp() ||8253 mHWData.isBackedUp() ||8254 mMediaData.isBackedUp() ||8255 mStorageControllers.isBackedUp() ||8256 #ifdef VBOX_WITH_VRDP8257 (mVRDPServer && mVRDPServer->isModified()) ||8258 #endif8259 (mAudioAdapter && mAudioAdapter->isModified()) ||8260 (mUSBController && mUSBController->isModified()) ||8261 (mBIOSSettings && mBIOSSettings->isModified());8262 }8263 8264 /**8265 8261 * Discards all changes to machine settings. 8266 8262 * … … 8275 8271 8276 8272 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 8277 8278 /* check for changes in own data */8279 8280 bool sharedFoldersChanged = false, storageChanged = false;8281 8282 if (aNotify && mHWData.isBackedUp())8283 {8284 if (mHWData->mSharedFolders.size() != mHWData.backedUpData()->mSharedFolders.size())8285 sharedFoldersChanged = true;8286 else8287 {8288 for (HWData::SharedFolderList::iterator rit = mHWData->mSharedFolders.begin();8289 rit != mHWData->mSharedFolders.end() && !sharedFoldersChanged;8290 ++rit)8291 {8292 for (HWData::SharedFolderList::iterator cit = mHWData.backedUpData()->mSharedFolders.begin();8293 cit != mHWData.backedUpData()->mSharedFolders.end();8294 ++cit)8295 {8296 if ( (*cit)->getName() != (*rit)->getName()8297 || (*cit)->getHostPath() != (*rit)->getHostPath()8298 )8299 {8300 sharedFoldersChanged = true;8301 break;8302 }8303 }8304 }8305 }8306 }8307 8273 8308 8274 if (!mStorageControllers.isNull()) … … 8329 8295 8330 8296 /* rollback any changes to devices after restoring the list */ 8331 StorageControllerList::const_iterator it = mStorageControllers->begin(); 8332 while (it != mStorageControllers->end()) 8333 { 8334 if ((*it)->isModified()) 8297 if (m_flModifications & IsModified_Storage) 8298 { 8299 StorageControllerList::const_iterator it = mStorageControllers->begin(); 8300 while (it != mStorageControllers->end()) 8301 { 8335 8302 (*it)->rollback(); 8336 8337 ++it;8303 ++it; 8304 } 8338 8305 } 8339 8306 } … … 8343 8310 mHWData.rollback(); 8344 8311 8345 if (m MediaData.isBackedUp())8312 if (m_flModifications & IsModified_Storage) 8346 8313 rollbackMedia(); 8347 8314 8348 /* check for changes in child objects */ 8349 bool vrdpChanged = false, usbChanged = false; 8315 if (mBIOSSettings) 8316 mBIOSSettings->rollback(); 8317 8318 #ifdef VBOX_WITH_VRDP 8319 if (mVRDPServer && (m_flModifications & IsModified_VRDPServer)) 8320 mVRDPServer->rollback(); 8321 #endif 8322 8323 if (mAudioAdapter) 8324 mAudioAdapter->rollback(); 8325 8326 if (mUSBController && (m_flModifications & IsModified_USB)) 8327 mUSBController->rollback(); 8350 8328 8351 8329 ComPtr<INetworkAdapter> networkAdapters[RT_ELEMENTS(mNetworkAdapters)]; … … 8353 8331 ComPtr<IParallelPort> parallelPorts[RT_ELEMENTS(mParallelPorts)]; 8354 8332 8355 if (mBIOSSettings) 8356 mBIOSSettings->rollback(); 8357 8358 #ifdef VBOX_WITH_VRDP 8359 if (mVRDPServer) 8360 vrdpChanged = mVRDPServer->rollback(); 8361 #endif 8362 8363 if (mAudioAdapter) 8364 mAudioAdapter->rollback(); 8365 8366 if (mUSBController) 8367 usbChanged = mUSBController->rollback(); 8368 8369 for (ULONG slot = 0; slot < RT_ELEMENTS(mNetworkAdapters); slot++) 8370 if (mNetworkAdapters[slot]) 8371 if (mNetworkAdapters[slot]->rollback()) 8372 networkAdapters[slot] = mNetworkAdapters[slot]; 8373 8374 for (ULONG slot = 0; slot < RT_ELEMENTS(mSerialPorts); slot++) 8375 if (mSerialPorts[slot]) 8376 if (mSerialPorts[slot]->rollback()) 8377 serialPorts[slot] = mSerialPorts[slot]; 8378 8379 for (ULONG slot = 0; slot < RT_ELEMENTS(mParallelPorts); slot++) 8380 if (mParallelPorts[slot]) 8381 if (mParallelPorts[slot]->rollback()) 8382 parallelPorts[slot] = mParallelPorts[slot]; 8333 if (m_flModifications & IsModified_NetworkAdapters) 8334 for (ULONG slot = 0; slot < RT_ELEMENTS(mNetworkAdapters); slot++) 8335 if (mNetworkAdapters[slot]) 8336 if (mNetworkAdapters[slot]->rollback()) 8337 networkAdapters[slot] = mNetworkAdapters[slot]; 8338 8339 if (m_flModifications & IsModified_SerialPorts) 8340 for (ULONG slot = 0; slot < RT_ELEMENTS(mSerialPorts); slot++) 8341 if (mSerialPorts[slot]) 8342 if (mSerialPorts[slot]->rollback()) 8343 serialPorts[slot] = mSerialPorts[slot]; 8344 8345 if (m_flModifications & IsModified_ParallelPorts) 8346 for (ULONG slot = 0; slot < RT_ELEMENTS(mParallelPorts); slot++) 8347 if (mParallelPorts[slot]) 8348 if (mParallelPorts[slot]->rollback()) 8349 parallelPorts[slot] = mParallelPorts[slot]; 8383 8350 8384 8351 if (aNotify) … … 8387 8354 8388 8355 ComObjPtr<Machine> that = this; 8356 uint32_t flModifications = m_flModifications; 8389 8357 alock.leave(); 8390 8358 8391 if ( sharedFoldersChanged)8359 if (flModifications & IsModified_SharedFolders) 8392 8360 that->onSharedFolderChange(); 8393 8361 8394 if ( vrdpChanged)8362 if (flModifications & IsModified_VRDPServer) 8395 8363 that->onVRDPServerChange(); 8396 if ( usbChanged)8364 if (flModifications & IsModified_USB) 8397 8365 that->onUSBControllerChange(); 8398 8366 … … 8407 8375 that->onParallelPortChange(parallelPorts[slot]); 8408 8376 8409 if ( storageChanged)8377 if (flModifications & IsModified_Storage) 8410 8378 that->onStorageControllerChange(); 8411 8379 } … … 8593 8561 8594 8562 for (ULONG slot = 0; slot < RT_ELEMENTS (mNetworkAdapters); slot ++) 8595 mNetworkAdapters 8563 mNetworkAdapters[slot]->copyFrom (aThat->mNetworkAdapters [slot]); 8596 8564 for (ULONG slot = 0; slot < RT_ELEMENTS (mSerialPorts); slot ++) 8597 mSerialPorts 8565 mSerialPorts[slot]->copyFrom (aThat->mSerialPorts [slot]); 8598 8566 for (ULONG slot = 0; slot < RT_ELEMENTS (mParallelPorts); slot ++) 8599 mParallelPorts 8567 mParallelPorts[slot]->copyFrom (aThat->mParallelPorts [slot]); 8600 8568 } 8601 8569 … … 8919 8887 /* We need to lock this object in uninit() because the lock is shared 8920 8888 * with mPeer (as well as data we modify below). mParent->addProcessToReap() 8921 * and others need mParent lock . */8922 AutoMultiWriteLock 2 alock(mParent, this COMMA_LOCKVAL_SRC_POS);8889 * and others need mParent lock, and USB needs host lock. */ 8890 AutoMultiWriteLock3 alock(mParent, mParent->host(), this COMMA_LOCKVAL_SRC_POS); 8923 8891 8924 8892 #ifdef VBOX_WITH_RESOURCE_USAGE_API 8925 unregisterMetrics 8893 unregisterMetrics(mParent->performanceCollector(), mPeer); 8926 8894 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 8927 8895 … … 8936 8904 /* reset the state to Aborted */ 8937 8905 if (mData->mMachineState != MachineState_Aborted) 8938 setMachineState (MachineState_Aborted); 8939 } 8940 8941 if (isModified()) 8906 setMachineState(MachineState_Aborted); 8907 } 8908 8909 // any machine settings modified? 8910 if (m_flModifications) 8942 8911 { 8943 8912 LogWarningThisFunc(("Discarding unsaved settings changes!\n")); … … 9593 9562 9594 9563 DiscardSettings(); 9564 setModified(IsModified_MachineData); 9595 9565 mHWData.backup(); 9596 9566 … … 9672 9642 } 9673 9643 9644 setModified(IsModified_MachineData); 9674 9645 mHWData.backup(); 9675 9646 … … 9869 9840 9870 9841 AutoCaller autoCaller(this); 9871 AssertComRCReturn 9842 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 9872 9843 9873 9844 ComPtr<IInternalSessionControl> directControl; … … 9881 9852 return S_OK; 9882 9853 9883 return directControl->OnParallelPortChange 9854 return directControl->OnParallelPortChange(parallelPort); 9884 9855 } 9885 9856 -
trunk/src/VBox/Main/MediumAttachmentImpl.cpp
r25860 r26167 373 373 } 374 374 375 /** Must be called from under this object's write lock. */375 /** Must be called from under this object's AND the machine's write lock. */ 376 376 void MediumAttachment::updateMedium(const ComObjPtr<Medium> &aMedium, bool aImplicit) 377 377 { 378 Assert(m->pMachine->isWriteLockOnCurrentThread()); 379 Assert(isWriteLockOnCurrentThread()); 380 378 381 m->bd.backup(); 379 382 m->bd->pMedium = aMedium; 380 383 m->bd->fImplicit = aImplicit; 381 } 382 383 /** Must be called from under this object's write lock. */ 384 385 m->pMachine->setModified(Machine::IsModified_Storage); 386 } 387 388 /** Must be called from under this object's AND the machine's write lock. */ 384 389 void MediumAttachment::updatePassthrough(bool aPassthrough) 385 390 { 391 Assert(m->pMachine->isWriteLockOnCurrentThread()); 392 Assert(isWriteLockOnCurrentThread()); 393 386 394 m->bd.backup(); 387 395 m->bd->fPassthrough = aPassthrough; 388 } 389 396 397 m->pMachine->setModified(Machine::IsModified_Storage); 398 } 399 -
trunk/src/VBox/Main/NetworkAdapterImpl.cpp
r26046 r26167 46 46 void NetworkAdapter::FinalRelease() 47 47 { 48 uninit 48 uninit(); 49 49 } 50 50 … … 57 57 * @param aParent Handle of the parent object. 58 58 */ 59 HRESULT NetworkAdapter::init 59 HRESULT NetworkAdapter::init(Machine *aParent, ULONG aSlot) 60 60 { 61 61 LogFlowThisFunc(("aParent=%p, aSlot=%d\n", aParent, aSlot)); … … 70 70 unconst(mParent) = aParent; 71 71 /* mPeer is left null */ 72 73 m_fModified = false; 72 74 73 75 mData.allocate(); … … 100 102 * @note Locks @a aThat object for reading. 101 103 */ 102 HRESULT NetworkAdapter::init 104 HRESULT NetworkAdapter::init(Machine *aParent, NetworkAdapter *aThat) 103 105 { 104 106 LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat)); … … 132 134 * @note Locks @a aThat object for reading. 133 135 */ 134 HRESULT NetworkAdapter::initCopy 136 HRESULT NetworkAdapter::initCopy(Machine *aParent, NetworkAdapter *aThat) 135 137 { 136 138 LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat)); … … 229 231 mData->mAdapterType = aAdapterType; 230 232 231 /* leave the lock before informing callbacks */ 232 alock.release(); 233 m_fModified = true; 234 // leave the lock before informing callbacks 235 alock.release(); 236 237 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 238 mParent->setModified(Machine::IsModified_NetworkAdapters); 239 mlock.release(); 233 240 234 241 mParent->onNetworkAdapterChange (this, FALSE); … … 282 289 mData->mEnabled = aEnabled; 283 290 284 /* leave the lock before informing callbacks */ 285 alock.release(); 291 m_fModified = true; 292 // leave the lock before informing callbacks 293 alock.release(); 294 295 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 296 mParent->setModified(Machine::IsModified_NetworkAdapters); 297 mlock.release(); 286 298 287 299 mParent->onNetworkAdapterChange (this, FALSE); … … 315 327 AutoMutableStateDependency adep(mParent); 316 328 if (FAILED(adep.rc())) return adep.rc(); 317 318 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);319 329 320 330 HRESULT rc = S_OK; … … 326 336 if (!aMACAddress || !*aMACAddress) 327 337 { 338 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 328 339 mData.backup(); 329 340 330 341 generateMACAddress(); 331 342 emitChangeEvent = true; 343 344 m_fModified = true; 345 // leave the lock before informing callbacks 346 alock.release(); 347 348 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 349 mParent->setModified(Machine::IsModified_NetworkAdapters); 350 mlock.release(); 332 351 } 333 352 else 334 353 { 354 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 335 355 if (mData->mMACAddress != aMACAddress) 336 356 { … … 371 391 372 392 mData->mMACAddress = macAddressUtf; 393 373 394 emitChangeEvent = true; 395 396 m_fModified = true; 397 // leave the lock before informing callbacks 398 alock.release(); 399 400 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 401 mParent->setModified(Machine::IsModified_NetworkAdapters); 402 mlock.release(); 374 403 } 375 404 } 376 405 } 377 406 407 // we have left the lock in any case at this point 408 378 409 if (emitChangeEvent) 379 {380 /* leave the lock before informing callbacks */381 alock.release();382 383 410 mParent->onNetworkAdapterChange (this, FALSE); 384 }385 411 386 412 return rc; … … 436 462 mData->mHostInterface = aHostInterface; 437 463 438 /* leave the lock before informing callbacks */ 439 alock.release(); 440 441 mParent->onNetworkAdapterChange (this, FALSE); 464 m_fModified = true; 465 // leave the lock before informing callbacks 466 alock.release(); 467 468 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 469 mParent->setModified(Machine::IsModified_NetworkAdapters); 470 mlock.release(); 471 472 mParent->onNetworkAdapterChange(this, FALSE); 442 473 } 443 474 … … 484 515 mData->mInternalNetwork = aInternalNetwork; 485 516 486 /* leave the lock before informing callbacks */ 487 alock.release(); 488 489 mParent->onNetworkAdapterChange (this, FALSE); 517 m_fModified = true; 518 // leave the lock before informing callbacks 519 alock.release(); 520 521 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 522 mParent->setModified(Machine::IsModified_NetworkAdapters); 523 mlock.release(); 524 525 mParent->onNetworkAdapterChange(this, FALSE); 490 526 } 491 527 … … 527 563 mData->mNATNetwork = aNATNetwork; 528 564 529 /* leave the lock before informing callbacks */ 530 alock.release(); 531 532 mParent->onNetworkAdapterChange (this, FALSE); 565 m_fModified = true; 566 // leave the lock before informing callbacks 567 alock.release(); 568 569 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 570 mParent->setModified(Machine::IsModified_NetworkAdapters); 571 mlock.release(); 572 573 mParent->onNetworkAdapterChange(this, FALSE); 533 574 } 534 575 … … 566 607 mData->mCableConnected = aConnected; 567 608 568 /* leave the lock before informing callbacks */ 569 alock.release(); 570 571 mParent->onNetworkAdapterChange (this, FALSE); 609 m_fModified = true; 610 // leave the lock before informing callbacks 611 alock.release(); 612 613 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 614 mParent->setModified(Machine::IsModified_NetworkAdapters); 615 mlock.release(); 616 617 mParent->onNetworkAdapterChange(this, FALSE); 572 618 } 573 619 … … 605 651 mData->mLineSpeed = aSpeed; 606 652 607 /* leave the lock before informing callbacks */ 608 alock.release(); 609 610 mParent->onNetworkAdapterChange (this, FALSE); 653 m_fModified = true; 654 // leave the lock before informing callbacks 655 alock.release(); 656 657 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 658 mParent->setModified(Machine::IsModified_NetworkAdapters); 659 mlock.release(); 660 661 mParent->onNetworkAdapterChange(this, FALSE); 611 662 } 612 663 … … 643 694 mData->mTraceEnabled = aEnabled; 644 695 645 /* leave the lock before informing callbacks */ 646 alock.release(); 647 648 mParent->onNetworkAdapterChange (this, TRUE); 696 m_fModified = true; 697 // leave the lock before informing callbacks 698 alock.release(); 699 700 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 701 mParent->setModified(Machine::IsModified_NetworkAdapters); 702 mlock.release(); 703 704 mParent->onNetworkAdapterChange(this, TRUE); 649 705 } 650 706 … … 682 738 mData->mTraceFile = aTraceFile; 683 739 684 /* leave the lock before informing callbacks */ 685 alock.release(); 686 687 mParent->onNetworkAdapterChange (this, FALSE); 740 m_fModified = true; 741 // leave the lock before informing callbacks 742 alock.release(); 743 744 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 745 mParent->setModified(Machine::IsModified_NetworkAdapters); 746 mlock.release(); 747 748 mParent->onNetworkAdapterChange(this, FALSE); 688 749 } 689 750 … … 715 776 mData->mAttachmentType = NetworkAttachmentType_NAT; 716 777 717 /* leave the lock before informing callbacks */ 718 alock.release(); 778 m_fModified = true; 779 // leave the lock before informing callbacks 780 alock.release(); 781 782 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 783 mParent->setModified(Machine::IsModified_NetworkAdapters); 784 mlock.release(); 719 785 720 786 HRESULT rc = mParent->onNetworkAdapterChange (this, TRUE); … … 757 823 mData->mAttachmentType = NetworkAttachmentType_Bridged; 758 824 759 /* leave the lock before informing callbacks */ 760 alock.release(); 825 m_fModified = true; 826 // leave the lock before informing callbacks 827 alock.release(); 828 829 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 830 mParent->setModified(Machine::IsModified_NetworkAdapters); 831 mlock.release(); 761 832 762 833 HRESULT rc = mParent->onNetworkAdapterChange (this, TRUE); … … 807 878 mData->mAttachmentType = NetworkAttachmentType_Internal; 808 879 809 /* leave the lock before informing callbacks */ 810 alock.release(); 880 m_fModified = true; 881 // leave the lock before informing callbacks 882 alock.release(); 883 884 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 885 mParent->setModified(Machine::IsModified_NetworkAdapters); 886 mlock.release(); 811 887 812 888 HRESULT rc = mParent->onNetworkAdapterChange (this, TRUE); … … 849 925 mData->mAttachmentType = NetworkAttachmentType_HostOnly; 850 926 851 /* leave the lock before informing callbacks */ 852 alock.release(); 927 m_fModified = true; 928 // leave the lock before informing callbacks 929 alock.release(); 930 931 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 932 mParent->setModified(Machine::IsModified_NetworkAdapters); 933 mlock.release(); 853 934 854 935 HRESULT rc = mParent->onNetworkAdapterChange (this, TRUE); … … 885 966 detach(); 886 967 887 /* leave the lock before informing callbacks */ 888 alock.release(); 968 m_fModified = true; 969 // leave the lock before informing callbacks 970 alock.release(); 971 972 AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS); // mParent is const, no need to lock 973 mParent->setModified(Machine::IsModified_NetworkAdapters); 974 mlock.release(); 889 975 890 976 mParent->onNetworkAdapterChange (this, TRUE); … … 976 1062 } 977 1063 1064 // after loading settings, we are no longer different from the XML on disk 1065 m_fModified = false; 1066 978 1067 return S_OK; 979 1068 } … … 1029 1118 break; 1030 1119 } 1120 1121 // after saving settings, we are no longer different from the XML on disk 1122 m_fModified = false; 1031 1123 1032 1124 return S_OK; -
trunk/src/VBox/Main/ParallelPortImpl.cpp
r26156 r26167 42 42 { 43 43 Data() 44 : fModified(false) 44 45 { } 46 47 bool fModified; 45 48 46 49 const ComObjPtr<Machine, ComWeakRef> pMachine; … … 232 235 m->bd->fEnabled = aEnabled; 233 236 234 /* leave the lock before informing callbacks */ 237 m->fModified = true; 238 // leave the lock before informing callbacks 235 239 alock.release(); 236 240 237 m->pMachine->onParallelPortChange (this); 241 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 242 m->pMachine->setModified(Machine::IsModified_ParallelPorts); 243 mlock.release(); 244 245 m->pMachine->onParallelPortChange(this); 238 246 } 239 247 … … 288 296 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 289 297 290 HRESULT rc = S_OK;291 bool emitChangeEvent = false;292 293 298 if (m->bd->ulIRQ != aIRQ) 294 299 { 295 300 m->bd.backup(); 296 301 m->bd->ulIRQ = aIRQ; 297 emitChangeEvent = true; 302 303 m->fModified = true; 304 // leave the lock before informing callbacks 305 alock.release(); 306 307 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 308 m->pMachine->setModified(Machine::IsModified_ParallelPorts); 309 mlock.release(); 310 311 m->pMachine->onParallelPortChange(this); 298 312 } 299 313 300 if (emitChangeEvent) 301 { 302 /* leave the lock before informing callbacks */ 303 alock.release(); 304 305 m->pMachine->onParallelPortChange (this); 306 } 307 308 return rc; 314 return S_OK; 309 315 } 310 316 … … 342 348 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 343 349 344 HRESULT rc = S_OK;345 bool emitChangeEvent = false;346 347 350 if (m->bd->ulIOBase != aIOBase) 348 351 { 349 352 m->bd.backup(); 350 353 m->bd->ulIOBase = aIOBase; 351 emitChangeEvent = true; 354 355 m->fModified = true; 356 // leave the lock before informing callbacks 357 alock.release(); 358 359 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 360 m->pMachine->setModified(Machine::IsModified_ParallelPorts); 361 mlock.release(); 362 363 m->pMachine->onParallelPortChange(this); 352 364 } 353 365 354 if (emitChangeEvent) 355 { 356 /* leave the lock before informing callbacks */ 357 alock.release(); 358 359 m->pMachine->onParallelPortChange (this); 360 } 361 362 return rc; 366 return S_OK; 363 367 } 364 368 … … 397 401 m->bd->strPath = str; 398 402 399 /* leave the lock before informing callbacks */ 403 m->fModified = true; 404 // leave the lock before informing callbacks 400 405 alock.release(); 406 407 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 408 m->pMachine->setModified(Machine::IsModified_ParallelPorts); 409 mlock.release(); 401 410 402 411 return m->pMachine->onParallelPortChange(this); … … 450 459 451 460 return S_OK; 452 }453 454 bool ParallelPort::isModified()455 {456 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);457 return m->bd.isBackedUp();458 461 } 459 462 -
trunk/src/VBox/Main/SerialPortImpl.cpp
r26156 r26167 43 43 { 44 44 Data() 45 : fModified(false) 45 46 { } 47 48 bool fModified; 46 49 47 50 const ComObjPtr<Machine, ComWeakRef> pMachine; … … 228 231 m->bd->fEnabled = aEnabled; 229 232 230 /* leave the lock before informing callbacks */ 233 m->fModified = true; 234 // leave the lock before informing callbacks 231 235 alock.release(); 232 236 233 m->pMachine->onSerialPortChange (this); 237 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 238 m->pMachine->setModified(Machine::IsModified_SerialPorts); 239 mlock.release(); 240 241 m->pMachine->onSerialPortChange(this); 234 242 } 235 243 … … 261 269 262 270 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 263 264 HRESULT rc = S_OK;265 bool emitChangeEvent = false;266 271 267 272 if (m->bd->portMode != aHostMode) … … 271 276 case PortMode_RawFile: 272 277 if (m->bd->strPath.isEmpty()) 273 return setError 274 tr("Cannot set the raw file mode of the serial port %d "275 "because the file path is empty or null"),276 m->bd->ulSlot);278 return setError(E_INVALIDARG, 279 tr("Cannot set the raw file mode of the serial port %d " 280 "because the file path is empty or null"), 281 m->bd->ulSlot); 277 282 break; 278 283 case PortMode_HostPipe: 279 284 if (m->bd->strPath.isEmpty()) 280 return setError 281 tr("Cannot set the host pipe mode of the serial port %d "282 "because the pipe path is empty or null"),283 m->bd->ulSlot);285 return setError(E_INVALIDARG, 286 tr("Cannot set the host pipe mode of the serial port %d " 287 "because the pipe path is empty or null"), 288 m->bd->ulSlot); 284 289 break; 285 290 case PortMode_HostDevice: 286 291 if (m->bd->strPath.isEmpty()) 287 return setError 288 tr("Cannot set the host device mode of the serial port %d "289 "because the device path is empty or null"),290 m->bd->ulSlot);292 return setError(E_INVALIDARG, 293 tr("Cannot set the host device mode of the serial port %d " 294 "because the device path is empty or null"), 295 m->bd->ulSlot); 291 296 break; 292 297 case PortMode_Disconnected: … … 297 302 m->bd->portMode = aHostMode; 298 303 299 emitChangeEvent = true; 300 } 301 302 if (emitChangeEvent) 303 { 304 /* leave the lock before informing callbacks */ 304 m->fModified = true; 305 // leave the lock before informing callbacks 305 306 alock.release(); 306 307 307 m->pMachine->onSerialPortChange (this); 308 } 309 310 return rc; 308 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 309 m->pMachine->setModified(Machine::IsModified_SerialPorts); 310 mlock.release(); 311 312 m->pMachine->onSerialPortChange(this); 313 } 314 315 return S_OK; 311 316 } 312 317 … … 358 363 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 359 364 360 HRESULT rc = S_OK;361 bool emitChangeEvent = false;362 363 365 if (m->bd->ulIRQ != aIRQ) 364 366 { 365 367 m->bd.backup(); 366 368 m->bd->ulIRQ = aIRQ; 367 emitChangeEvent = true; 368 } 369 370 if (emitChangeEvent) 371 { 372 /* leave the lock before informing callbacks */ 369 370 m->fModified = true; 371 // leave the lock before informing callbacks 373 372 alock.release(); 374 373 375 m->pMachine->onSerialPortChange (this); 376 } 377 378 return rc; 374 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 375 m->pMachine->setModified(Machine::IsModified_SerialPorts); 376 mlock.release(); 377 378 m->pMachine->onSerialPortChange(this); 379 } 380 381 return S_OK; 379 382 } 380 383 … … 413 416 414 417 HRESULT rc = S_OK; 415 bool emitChangeEvent = false;416 418 417 419 if (m->bd->ulIOBase != aIOBase) … … 419 421 m->bd.backup(); 420 422 m->bd->ulIOBase = aIOBase; 421 emitChangeEvent = true; 422 } 423 424 if (emitChangeEvent) 425 { 426 /* leave the lock before informing callbacks */ 423 424 m->fModified = true; 425 // leave the lock before informing callbacks 427 426 alock.release(); 428 427 429 m->pMachine->onSerialPortChange (this); 428 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 429 m->pMachine->setModified(Machine::IsModified_SerialPorts); 430 mlock.release(); 431 432 m->pMachine->onSerialPortChange(this); 430 433 } 431 434 … … 471 474 m->bd->strPath = str; 472 475 473 /* leave the lock before informing callbacks */ 476 m->fModified = true; 477 // leave the lock before informing callbacks 474 478 alock.release(); 475 479 476 return m->pMachine->onSerialPortChange(this); 480 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 481 m->pMachine->setModified(Machine::IsModified_SerialPorts); 482 mlock.release(); 483 484 m->pMachine->onSerialPortChange(this); 477 485 } 478 486 … … 510 518 m->bd->fServer = aServer; 511 519 512 /* leave the lock before informing callbacks */ 520 m->fModified = true; 521 // leave the lock before informing callbacks 513 522 alock.release(); 514 523 515 m->pMachine->onSerialPortChange (this); 524 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 525 m->pMachine->setModified(Machine::IsModified_SerialPorts); 526 mlock.release(); 527 528 m->pMachine->onSerialPortChange(this); 516 529 } 517 530 … … 563 576 564 577 return S_OK; 565 }566 567 bool SerialPort::isModified()568 {569 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);570 return m->bd.isBackedUp();571 578 } 572 579 -
trunk/src/VBox/Main/SnapshotImpl.cpp
r26088 r26167 1319 1319 // backup the media data so we can recover if things goes wrong along the day; 1320 1320 // the matching commit() is in fixupMedia() during endSnapshot() 1321 setModified(IsModified_Storage); 1321 1322 mMediaData.backup(); 1322 1323 … … 1669 1670 * the machine is powered off, so there is no need to inform the direct 1670 1671 * session) */ 1671 if ( isModified())1672 if (m_flModifications) 1672 1673 rollback(false /* aNotify */); 1673 1674 … … 1707 1708 LogFlowThisFunc(("Restoring hard disks from the snapshot...\n")); 1708 1709 1709 /* restore the attachments from the snapshot */ 1710 // restore the attachments from the snapshot 1711 setModified(IsModified_Storage); 1710 1712 mMediaData.backup(); 1711 1713 mMediaData->mAttachments = pSnapshotMachine->mMediaData->mAttachments; … … 1977 1979 if (pSnapshot == mData->mCurrentSnapshot) 1978 1980 { 1979 if ( isModified())1981 if (m_flModifications) 1980 1982 { 1981 1983 rc = saveSettings(); -
trunk/src/VBox/Main/StorageControllerImpl.cpp
r26156 r26167 577 577 m->bd->mPortCount = aPortCount; 578 578 579 /* leave the lock for safety */ 580 alock.leave(); 581 582 m->pParent->onStorageControllerChange (); 579 alock.release(); 580 AutoWriteLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS); // m->pParent is const, needs no locking 581 m->pParent->setModified(Machine::IsModified_Storage); 582 mlock.release(); 583 584 m->pParent->onStorageControllerChange(); 583 585 } 584 586 … … 713 715 { 714 716 return m->bd->mInstance; 715 }716 717 bool StorageController::isModified()718 {719 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);720 return m->bd.isBackedUp();721 717 } 722 718 -
trunk/src/VBox/Main/USBControllerImpl.cpp
r26156 r26167 299 299 m->bd->fEnabled = aEnabled; 300 300 301 /* leave the lock for safety */ 302 alock.leave(); 301 // leave the lock for safety 302 alock.release(); 303 304 AutoWriteLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS); 305 m->pParent->setModified(Machine::IsModified_USB); 306 mlock.release(); 303 307 304 308 m->pParent->onUSBControllerChange(); … … 340 344 m->bd->fEnabledEHCI = aEnabled; 341 345 342 /* leave the lock for safety */ 343 alock.leave(); 346 // leave the lock for safety 347 alock.release(); 348 349 AutoWriteLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS); 350 m->pParent->setModified(Machine::IsModified_USB); 351 mlock.release(); 344 352 345 353 m->pParent->onUSBControllerChange(); … … 470 478 } 471 479 472 STDMETHODIMP USBController::InsertDeviceFilter 473 480 STDMETHODIMP USBController::InsertDeviceFilter(ULONG aPosition, 481 IUSBDeviceFilter *aFilter) 474 482 { 475 483 #ifdef VBOX_WITH_USB … … 495 503 496 504 if (filter->mInList) 497 return setError 498 tr("The given USB device filter is already in the list"));505 return setError(VBOX_E_INVALID_OBJECT_STATE, 506 tr("The given USB device filter is already in the list")); 499 507 500 508 /* backup the list before modification */ … … 523 531 filter->getId() = service->insertFilter (&filter->getData().mUSBFilter); 524 532 } 533 534 alock.release(); 535 AutoWriteLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS); 536 m->pParent->setModified(Machine::IsModified_USB); 537 mlock.release(); 525 538 526 539 return S_OK; … … 590 603 filter->getId() = NULL; 591 604 } 605 606 alock.release(); 607 AutoWriteLock mlock(m->pParent COMMA_LOCKVAL_SRC_POS); 608 m->pParent->setModified(Machine::IsModified_USB); 609 mlock.release(); 592 610 593 611 return S_OK; … … 706 724 707 725 return S_OK; 708 }709 710 /** @note Locks objects for reading! */711 bool USBController::isModified()712 {713 AutoCaller autoCaller(this);714 AssertComRCReturn (autoCaller.rc(), false);715 716 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);717 718 if (m->bd.isBackedUp()719 #ifdef VBOX_WITH_USB720 || m->llDeviceFilters.isBackedUp()721 #endif722 )723 return true;724 725 #ifdef VBOX_WITH_USB726 /* see whether any of filters has changed its data */727 for (DeviceFilterList::const_iterator728 it = m->llDeviceFilters->begin();729 it != m->llDeviceFilters->end();730 ++ it)731 {732 if ((*it)->isModified())733 return true;734 }735 #endif /* VBOX_WITH_USB */736 737 return false;738 726 } 739 727 -
trunk/src/VBox/Main/include/AudioAdapterImpl.h
r26156 r26167 92 92 HRESULT saveSettings(settings::AudioAdapter &data); 93 93 94 bool isModified();95 94 bool rollback(); 96 95 void commit(); -
trunk/src/VBox/Main/include/BIOSSettingsImpl.h
r26156 r26167 84 84 HRESULT saveSettings(settings::BIOSSettings &data); 85 85 86 bool isModified();87 86 void rollback(); 88 87 void commit(); -
trunk/src/VBox/Main/include/MachineImpl.h
r26156 r26167 575 575 const Bstr& getName() const { return mUserData->mName; } 576 576 577 enum 578 { 579 IsModified_MachineData = 0x0001, 580 IsModified_Storage = 0x0002, 581 IsModified_NetworkAdapters = 0x0008, 582 IsModified_SerialPorts = 0x0010, 583 IsModified_ParallelPorts = 0x0020, 584 IsModified_VRDPServer = 0x0040, 585 IsModified_AudioAdapter = 0x0080, 586 IsModified_USB = 0x0100, 587 IsModified_BIOS = 0x0200, 588 IsModified_SharedFolders = 0x0400 589 }; 590 591 void setModified(uint32_t fl); 592 577 593 // callback handlers 578 594 virtual HRESULT onNetworkAdapterChange(INetworkAdapter * /* networkAdapter */, BOOL /* changeAdapter */) { return S_OK; } … … 745 761 bool isInOwnDir(Utf8Str *aSettingsDir = NULL); 746 762 747 bool isModified();748 763 void rollback(bool aNotify); 749 764 void commit(); … … 759 774 const ComObjPtr<VirtualBox, ComWeakRef> mParent; 760 775 761 Shareable<Data> mData; 762 Shareable<SSData> mSSData; 763 764 Backupable<UserData> mUserData; 765 Backupable<HWData> mHWData; 766 Backupable<MediaData> mMediaData; 776 uint32_t m_flModifications; 777 778 Shareable<Data> mData; 779 Shareable<SSData> mSSData; 780 781 Backupable<UserData> mUserData; 782 Backupable<HWData> mHWData; 783 Backupable<MediaData> mMediaData; 767 784 768 785 // the following fields need special backup/rollback/commit handling, -
trunk/src/VBox/Main/include/NetworkAdapterImpl.h
r26156 r26167 139 139 HRESULT saveSettings(settings::NetworkAdapter &data); 140 140 141 bool isModified() { AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); return mData.isBackedUp(); }142 141 bool rollback(); 143 142 void commit(); … … 156 155 const ComObjPtr<NetworkAdapter> mPeer; 157 156 157 bool m_fModified; 158 158 Backupable<Data> mData; 159 159 }; -
trunk/src/VBox/Main/include/ParallelPortImpl.h
r26156 r26167 78 78 HRESULT saveSettings(settings::ParallelPort &data); 79 79 80 bool isModified();81 80 bool rollback(); 82 81 void commit(); -
trunk/src/VBox/Main/include/SerialPortImpl.h
r26156 r26167 84 84 HRESULT saveSettings(settings::SerialPort &data); 85 85 86 bool isModified();87 86 bool rollback(); 88 87 void commit(); -
trunk/src/VBox/Main/include/StorageControllerImpl.h
r26156 r26167 89 89 ULONG getInstance() const; 90 90 91 bool isModified();92 91 bool rollback(); 93 92 void commit(); -
trunk/src/VBox/Main/include/USBControllerImpl.h
r26156 r26167 83 83 HRESULT saveSettings(settings::USBController &data); 84 84 85 bool isModified();86 85 bool rollback(); 87 86 void commit(); -
trunk/src/VBox/Main/include/VRDPServerImpl.h
r26156 r26167 111 111 HRESULT saveSettings(settings::VRDPSettings &data); 112 112 113 bool isModified() { AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); return mData.isBackedUp(); }114 113 bool rollback(); 115 114 void commit();
Note:
See TracChangeset
for help on using the changeset viewer.