Changeset 15334 in vbox for trunk/src/VBox/Main
- Timestamp:
- Dec 11, 2008 7:37:55 PM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/DVDDriveImpl.cpp
r15051 r15334 275 275 if (SUCCEEDED (rc)) 276 276 { 277 mData.backup(); 278 279 unmount(); 280 281 mData->mImage = image; 282 mData->mState = DriveState_ImageMounted; 283 284 /* leave the lock before informing callbacks */ 285 alock.unlock(); 286 287 mParent->onDVDDriveChange(); 277 /* umount() will backup data */ 278 rc = unmount(); 279 if (SUCCEEDED (rc)) 280 { 281 mData->mImage = image; 282 mData->mState = DriveState_ImageMounted; 283 284 /* leave the lock before informing callbacks */ 285 alock.unlock(); 286 287 mParent->onDVDDriveChange(); 288 } 288 289 } 289 290 } … … 309 310 !mData->mHostDrive.equalsTo (aHostDVDDrive)) 310 311 { 311 mData.backup(); 312 313 unmount(); 314 315 mData->mHostDrive = aHostDVDDrive; 316 mData->mState = DriveState_HostDriveCaptured; 317 318 /* leave the lock before informing callbacks */ 319 alock.unlock(); 320 321 mParent->onDVDDriveChange(); 312 /* umount() will backup data */ 313 HRESULT rc = unmount(); 314 if (SUCCEEDED (rc)) 315 { 316 mData->mHostDrive = aHostDVDDrive; 317 mData->mState = DriveState_HostDriveCaptured; 318 319 /* leave the lock before informing callbacks */ 320 alock.unlock(); 321 322 mParent->onDVDDriveChange(); 323 } 322 324 } 323 325 … … 338 340 if (mData->mState != DriveState_NotMounted) 339 341 { 340 mData.backup(); 341 342 unmount(); 343 344 mData->mState = DriveState_NotMounted; 345 346 /* leave the lock before informing callbacks */ 347 alock.unlock(); 348 349 mParent->onDVDDriveChange(); 342 /* umount() will backup data */ 343 HRESULT rc = unmount(); 344 if (SUCCEEDED (rc)) 345 { 346 mData->mState = DriveState_NotMounted; 347 348 /* leave the lock before informing callbacks */ 349 alock.unlock(); 350 351 mParent->onDVDDriveChange(); 352 } 350 353 } 351 354 … … 385 388 386 389 /** 387 * Loads settings from the given machine node.388 * May be called once right afterthis object creation.389 * 390 * @param aMachineNode<Machine> node.391 * 392 * 390 * Loads settings from the given machine node. May be called once right after 391 * this object creation. 392 * 393 * @param aMachineNode <Machine> node. 394 * 395 * @note Locks this object for writing. 393 396 */ 394 397 HRESULT DVDDrive::loadSettings (const settings::Key &aMachineNode) … … 469 472 470 473 /** 471 * 472 * 473 * @param aMachineNode<Machine> node.474 * 475 * 474 * Saves settings to the given machine node. 475 * 476 * @param aMachineNode <Machine> node. 477 * 478 * @note Locks this object for reading. 476 479 */ 477 480 HRESULT DVDDrive::saveSettings (settings::Key &aMachineNode) … … 530 533 531 534 /** 532 * 535 * @note Locks this object for writing. 533 536 */ 534 537 bool DVDDrive::rollback() … … 567 570 568 571 /** 569 * @note Locks this object for writing, together with the peer object (also570 * forwriting) if there is one.572 * @note Locks this object for writing, together with the peer object (also for 573 * writing) if there is one. 571 574 */ 572 575 void DVDDrive::commit() … … 605 608 606 609 /** 607 * 608 * represented by @a aThat (locked for reading).610 * @note Locks this object for writing, together with the peer object 611 * represented by @a aThat (locked for reading). 609 612 */ 610 613 void DVDDrive::copyFrom (DVDDrive *aThat) … … 628 631 } 629 632 630 // private methods 631 //////////////////////////////////////////////////////////////////////////////// 632 633 /** 634 * Helper to unmount a drive. 635 * 636 * @return COM status code 637 * 633 /** 634 * Helper to unmount a drive. 635 * 636 * @note Must be called from under this object's write lock. 638 637 */ 639 638 HRESULT DVDDrive::unmount() 640 639 { 641 640 AssertReturn (isWriteLockOnCurrentThread(), E_FAIL); 641 642 mData.backup(); 642 643 643 644 if (mData->mImage) … … 646 647 mData->mHostDrive.setNull(); 647 648 648 return S_OK; 649 } 649 mData->mState = DriveState_NotMounted; 650 651 return S_OK; 652 } 653 654 // private methods 655 //////////////////////////////////////////////////////////////////////////////// 656 650 657 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/FloppyDriveImpl.cpp
r15051 r15334 282 282 if (SUCCEEDED (rc)) 283 283 { 284 mData.backup(); 285 286 unmount(); 287 288 mData->mImage = image; 289 mData->mState = DriveState_ImageMounted; 290 291 /* leave the lock before informing callbacks */ 292 alock.unlock(); 293 294 mParent->onFloppyDriveChange(); 284 /* umount() will backup data */ 285 rc = unmount(); 286 if (SUCCEEDED (rc)) 287 { 288 mData->mImage = image; 289 mData->mState = DriveState_ImageMounted; 290 291 /* leave the lock before informing callbacks */ 292 alock.unlock(); 293 294 mParent->onFloppyDriveChange(); 295 } 295 296 } 296 297 } … … 316 317 !mData->mHostDrive.equalsTo (aHostFloppyDrive)) 317 318 { 318 mData.backup(); 319 320 unmount(); 321 322 mData->mHostDrive = aHostFloppyDrive; 323 mData->mState = DriveState_HostDriveCaptured; 324 325 /* leave the lock before informing callbacks */ 326 alock.unlock(); 327 328 mParent->onFloppyDriveChange(); 319 /* umount() will backup data */ 320 HRESULT rc = unmount(); 321 if (SUCCEEDED (rc)) 322 { 323 mData->mHostDrive = aHostFloppyDrive; 324 mData->mState = DriveState_HostDriveCaptured; 325 326 /* leave the lock before informing callbacks */ 327 alock.unlock(); 328 329 mParent->onFloppyDriveChange(); 330 } 329 331 } 330 332 … … 345 347 if (mData->mState != DriveState_NotMounted) 346 348 { 347 mData.backup(); 348 349 unmount(); 350 351 mData->mState = DriveState_NotMounted; 352 353 /* leave the lock before informing callbacks */ 354 alock.unlock(); 355 356 mParent->onFloppyDriveChange(); 349 /* umount() will backup data */ 350 HRESULT rc = unmount(); 351 if (SUCCEEDED (rc)) 352 { 353 mData->mState = DriveState_NotMounted; 354 355 /* leave the lock before informing callbacks */ 356 alock.unlock(); 357 358 mParent->onFloppyDriveChange(); 359 } 357 360 } 358 361 … … 392 395 393 396 /** 394 * Loads settings from the given machine node.395 * May be called once right afterthis object creation.396 * 397 * @param aMachineNode<Machine> node.398 * 399 * 397 * Loads settings from the given machine node. May be called once right after 398 * this object creation. 399 * 400 * @param aMachineNode <Machine> node. 401 * 402 * @note Locks this object for writing. 400 403 */ 401 404 HRESULT FloppyDrive::loadSettings (const settings::Key &aMachineNode) … … 476 479 477 480 /** 478 * 479 * 480 * @param aMachineNode<Machine> node.481 * 482 * 481 * Saves settings to the given machine node. 482 * 483 * @param aMachineNode <Machine> node. 484 * 485 * @note Locks this object for reading. 483 486 */ 484 487 HRESULT FloppyDrive::saveSettings (settings::Key &aMachineNode) … … 537 540 538 541 /** 539 * 542 * @note Locks this object for writing. 540 543 */ 541 544 bool FloppyDrive::rollback() … … 574 577 575 578 /** 576 * @note Locks this object for writing, together with the peer object (also577 * forwriting) if there is one.579 * @note Locks this object for writing, together with the peer object (also for 580 * writing) if there is one. 578 581 */ 579 582 void FloppyDrive::commit() … … 612 615 613 616 /** 614 * 615 * for reading) if there is one.617 * @note Locks this object for writing, together with the peer object (locked 618 * for reading) if there is one. 616 619 */ 617 620 void FloppyDrive::copyFrom (FloppyDrive *aThat) … … 633 636 } 634 637 635 // private methods 636 ///////////////////////////////////////////////////////////////////////////// 637 638 /** 639 * Helper to unmount a drive. 640 * 641 * @return COM status code 638 /** 639 * Helper to unmount a drive. 640 * 641 * @note Must be called from under this object's write lock. 642 642 */ 643 643 HRESULT FloppyDrive::unmount() 644 644 { 645 645 AssertReturn (isWriteLockOnCurrentThread(), E_FAIL); 646 647 mData.backup(); 646 648 647 649 if (mData->mImage) … … 650 652 mData->mHostDrive.setNull(); 651 653 652 return S_OK; 653 } 654 mData->mState = DriveState_NotMounted; 655 656 return S_OK; 657 } 658 659 // private methods 660 ///////////////////////////////////////////////////////////////////////////// 661 654 662 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/MachineImpl.cpp
r15202 r15334 4102 4102 AssertReturn (autoCaller.state() == Ready, E_FAIL); 4103 4103 4104 /* we will probably modify these and want to prevent concurrent 4105 * modifications until we finish */ 4106 AutoWriteLock dvdLock (mDVDDrive); 4107 AutoWriteLock floppyLock (mFloppyDrive); 4108 4104 4109 if (aRegistered) 4105 4110 { … … 4138 4143 "has %d hard disks attached"), 4139 4144 mUserData->mName.raw(), mHDData->mAttachments.size()); 4140 } 4145 4146 /* Note that we do not prevent unregistration of a DVD or Floppy image 4147 * is attached: as opposed to hard disks detaching such an image 4148 * implicitly in this method (which we will do below) won't have any 4149 * side effects (like detached orphan base and diff hard disks etc).*/ 4150 } 4151 4152 HRESULT rc = S_OK; 4141 4153 4142 4154 /* Ensure the settings are saved. If we are going to be registered and 4143 4155 * isConfigLocked() is FALSE then it means that no config file exists yet, 4144 * so create it . */4156 * so create it by calling saveSettings() too. */ 4145 4157 if (isModified() || (aRegistered && !isConfigLocked())) 4146 4158 { 4147 HRESULTrc = saveSettings();4159 rc = saveSettings(); 4148 4160 CheckComRCReturnRC (rc); 4149 4161 } 4150 4162 4151 mData->mRegistered = aRegistered; 4152 4153 return S_OK; 4163 /* Implicitly detach DVD/Floppy */ 4164 rc = mDVDDrive->unmount(); 4165 if (SUCCEEDED (rc)) 4166 rc = mFloppyDrive->unmount(); 4167 4168 if (SUCCEEDED (rc)) 4169 { 4170 /* we may have had implicit modifications we want to fix on success */ 4171 commit(); 4172 4173 mData->mRegistered = aRegistered; 4174 } 4175 else 4176 { 4177 /* we may have had implicit modifications we want to cancel on failure*/ 4178 rollback (false /* aNotify */); 4179 } 4180 4181 return rc; 4154 4182 } 4155 4183 -
trunk/src/VBox/Main/include/DVDDriveImpl.h
r15051 r15334 108 108 void copyFrom (DVDDrive *aThat); 109 109 110 HRESULT unmount(); 111 110 112 // public methods for internal purposes only 111 113 // (ensure there is a caller and a read lock before calling them!) … … 118 120 private: 119 121 120 HRESULT unmount();121 122 122 const ComObjPtr <Machine, ComWeakRef> mParent; 123 123 const ComObjPtr <DVDDrive> mPeer; -
trunk/src/VBox/Main/include/FloppyDriveImpl.h
r15051 r15334 108 108 void copyFrom (FloppyDrive *aThat); 109 109 110 HRESULT unmount(); 111 110 112 // public methods for internal purposes only 111 113 // (ensure there is a caller and a read lock before calling them!) … … 118 120 private: 119 121 120 HRESULT unmount();121 122 122 const ComObjPtr <Machine, ComWeakRef> mParent; 123 123 const ComObjPtr <FloppyDrive> mPeer;
Note:
See TracChangeset
for help on using the changeset viewer.