Changeset 50945 in vbox
- Timestamp:
- Apr 1, 2014 3:16:22 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ConsoleImpl.h
r50736 r50945 338 338 ~AutoVMCallerBase() 339 339 { 340 if (SUCCEEDED(mRC)) 341 mThat->releaseVMCaller(); 340 doRelease(); 342 341 } 343 342 /** Decreases the number of callers before the instance is destroyed. */ 344 343 void releaseCaller() 345 344 { 346 AssertReturnVoid(SUCCEEDED(mRC)); 347 mThat->releaseVMCaller(); 348 mRC = E_FAIL; 345 Assert(SUCCEEDED(mRC)); 346 doRelease(); 349 347 } 350 348 /** Restores the number of callers after by #release(). #rc() must be … … 361 359 protected: 362 360 Console *mThat; 363 HRESULT mRC; 361 void doRelease() 362 { 363 if (SUCCEEDED(mRC)) 364 { 365 mThat->releaseVMCaller(); 366 mRC = E_FAIL; 367 } 368 } 364 369 private: 370 HRESULT mRC; /* Whether the caller was added. */ 365 371 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(AutoVMCallerBase) 366 372 }; … … 422 428 typedef AutoVMCallerBase<taQuiet, true> Base; 423 429 public: 424 SafeVMPtrBase(Console *aThat) : Base(aThat), m pUVM(NULL)425 { 426 if ( SUCCEEDED(Base::mRC))427 Base::mRC = aThat->safeVMPtrRetainer(&mpUVM, taQuiet);430 SafeVMPtrBase(Console *aThat) : Base(aThat), mRC(S_OK), mpUVM(NULL) 431 { 432 if (Base::isOk()) 433 mRC = aThat->safeVMPtrRetainer(&mpUVM, taQuiet); 428 434 } 429 435 ~SafeVMPtrBase() 430 436 { 431 if (SUCCEEDED(Base::mRC)) 432 release(); 437 doRelease(); 433 438 } 434 439 /** Direct PUVM access. */ … … 437 442 void release() 438 443 { 439 AssertReturnVoid(SUCCEEDED(Base::mRC)); 440 Base::mThat->safeVMPtrReleaser(&mpUVM); 441 Base::releaseCaller(); 444 Assert(SUCCEEDED(mRC)); 445 doRelease(); 442 446 } 443 447 448 /** The combined result of Console::addVMCaller() and Console::safeVMPtrRetainer */ 449 HRESULT rc() const { return SUCCEEDED(mRC)? Base::rc(): mRC; } 450 /** Shortcut to SUCCEEDED(rc()) */ 451 bool isOk() const { return SUCCEEDED(mRC) && Base::isOk(); } 452 444 453 private: 454 void doRelease() 455 { 456 if (SUCCEEDED(mRC)) 457 { 458 Base::mThat->safeVMPtrReleaser(&mpUVM); 459 mRC = E_FAIL; 460 } 461 Base::doRelease(); 462 } 463 HRESULT mRC; /* Whether the VM ptr was retained. */ 445 464 PUVM mpUVM; 446 465 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(SafeVMPtrBase)
Note:
See TracChangeset
for help on using the changeset viewer.