Changeset 44402 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jan 27, 2013 11:17:46 PM (12 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ConsoleImpl.h
r44393 r44402 387 387 typedef AutoVMCallerBase<taQuiet, true> Base; 388 388 public: 389 SafeVMPtrBase(Console *aThat) : Base(aThat), mp VM(NULL), mpUVM(NULL)389 SafeVMPtrBase(Console *aThat) : Base(aThat), mpUVM(NULL) 390 390 { 391 391 if (SUCCEEDED(Base::mRC)) 392 Base::mRC = aThat->safeVMPtrRetainer(&mp VM, &mpUVM, taQuiet);392 Base::mRC = aThat->safeVMPtrRetainer(&mpUVM, taQuiet); 393 393 } 394 394 ~SafeVMPtrBase() … … 397 397 release(); 398 398 } 399 #if 1 /* to be removed... */ 400 /** Smart SaveVMPtr to PVM cast operator */ 401 operator PVM() const { return mpVM; } 402 #endif 403 /** Direct PVM access for printf()-like functions */ 404 PVM raw() const { return mpVM; } 405 /** Direct PUVM access for printf()-like functions */ 399 /** Direct PUVM access. */ 406 400 PUVM rawUVM() const { return mpUVM; } 407 401 /** Release the handles. */ … … 409 403 { 410 404 AssertReturnVoid(SUCCEEDED(Base::mRC)); 411 Base::mThat->safeVMPtrReleaser(&mp VM, &mpUVM);405 Base::mThat->safeVMPtrReleaser(&mpUVM); 412 406 Base::releaseCaller(); 413 407 } 414 408 415 409 private: 416 PVM mpVM;417 410 PUVM mpUVM; 418 411 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(SafeVMPtrBase) … … 422 415 423 416 /** 424 * Helper class that safely manages the Console::mp VM pointer417 * Helper class that safely manages the Console::mpUVM pointer 425 418 * by calling addVMCaller() on construction and releaseVMCaller() on 426 419 * destruction. Intended for Console children. The usage pattern is: … … 494 487 HRESULT addVMCaller(bool aQuiet = false, bool aAllowNullVM = false); 495 488 void releaseVMCaller(); 496 HRESULT safeVMPtrRetainer(P VM *a_ppVM, PUVM *a_ppUVM, bool aQuiet);497 void safeVMPtrReleaser(P VM *a_ppVM, PUVM *a_ppUVM);489 HRESULT safeVMPtrRetainer(PUVM *a_ppUVM, bool aQuiet); 490 void safeVMPtrReleaser(PUVM *a_ppUVM); 498 491 499 492 HRESULT consoleInitReleaseLog(const ComPtr<IMachine> aMachine); … … 744 737 /** The user mode VM handle. */ 745 738 PUVM mpUVM; 746 /** Holds the number of "readonly" mpVM callers (users) */739 /** Holds the number of "readonly" mpVM/mpUVM callers (users) */ 747 740 uint32_t mVMCallers; 748 741 /** Semaphore posted when the number of mpVM callers drops to zero */ -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r44393 r44402 156 156 mProgress(aProgress), 157 157 mServerProgress(aServerProgress), 158 mpVM(NULL),159 158 mpUVM(NULL), 160 159 mRC(E_FAIL), … … 169 168 mpSafeVMPtr = new Console::SafeVMPtr(aConsole); 170 169 if (mpSafeVMPtr->isOk()) 171 {172 mpVM = mpSafeVMPtr->raw();173 170 mpUVM = mpSafeVMPtr->rawUVM(); 174 }175 171 else 176 172 mRC = mpSafeVMPtr->rc(); … … 201 197 Utf8Str mErrorMsg; 202 198 const ComPtr<IProgress> mServerProgress; 203 PVM mpVM;204 199 PUVM mpUVM; 205 200 … … 2547 2542 2548 2543 #ifdef VBOX_WITH_EXTPACK 2549 int vrc = mptrExtPackManager->callAllVmPowerOnHooks(this, ptrVM.raw()); /** @todo called a few times too many... */2544 int vrc = mptrExtPackManager->callAllVmPowerOnHooks(this, VMR3GetVM(ptrVM.rawUVM())); /** @todo called a few times too many... */ 2550 2545 #else 2551 2546 int vrc = VINF_SUCCESS; … … 6176 6171 6177 6172 6178 HRESULT Console::safeVMPtrRetainer(PVM *a_ppVM, PUVM *a_ppUVM, bool a_Quiet) 6179 { 6180 *a_ppVM = NULL; 6173 HRESULT Console::safeVMPtrRetainer(PUVM *a_ppUVM, bool a_Quiet) 6174 { 6181 6175 *a_ppUVM = NULL; 6182 6176 … … 6190 6184 if (mVMDestroying) /* powerDown() is waiting for all callers to finish */ 6191 6185 return a_Quiet 6192 ? E_ACCESSDENIED6193 : setError(E_ACCESSDENIED, tr("The virtual machine is being powered down"));6186 ? E_ACCESSDENIED 6187 : setError(E_ACCESSDENIED, tr("The virtual machine is being powered down")); 6194 6188 PUVM pUVM = mpUVM; 6195 6189 if (!pUVM) 6196 6190 return a_Quiet 6197 ? E_ACCESSDENIED6198 : setError(E_ACCESSDENIED, tr("The virtual machine is powered off"));6191 ? E_ACCESSDENIED 6192 : setError(E_ACCESSDENIED, tr("The virtual machine is powered off")); 6199 6193 6200 6194 /* … … 6207 6201 : setError(E_ACCESSDENIED, tr("The virtual machine is powered off")); 6208 6202 6209 PVM pVM = VMR3GetVM(pUVM);6210 if (!pVM)6211 {6212 VMR3ReleaseUVM(pUVM);6213 return a_Quiet6214 ? E_ACCESSDENIED6215 : setError(E_ACCESSDENIED, tr("The virtual machine is powered off"));6216 }6217 6218 6203 /* done */ 6219 *a_ppVM = pVM;6220 6204 *a_ppUVM = pUVM; 6221 6205 return S_OK; 6222 6206 } 6223 6207 6224 void Console::safeVMPtrReleaser(P VM *a_ppVM, PUVM *a_ppUVM)6225 { 6226 if (*a_pp VM && *a_ppUVM)6208 void Console::safeVMPtrReleaser(PUVM *a_ppUVM) 6209 { 6210 if (*a_ppUVM) 6227 6211 VMR3ReleaseUVM(*a_ppUVM); 6228 *a_ppVM = NULL;6229 6212 *a_ppUVM = NULL; 6230 6213 } -
trunk/src/VBox/Main/src-client/DisplayImpl.cpp
r44382 r44402 2991 2991 return; 2992 2992 2993 #if DEBUG2993 #ifdef VBOX_STRICT 2994 2994 /* 2995 2995 * Sanity check. Note that this method may be called on EMT after Console … … 3000 3000 * time-critical method. 3001 3001 */ 3002 Console::SafeVMPtrQuiet ptrVM 3002 Console::SafeVMPtrQuiet ptrVM(mParent); 3003 3003 if (ptrVM.isOk()) 3004 Assert(VM_IS_EMT(ptrVM.raw())); 3004 { 3005 PVM pVM = VMR3GetVM(ptrVM.rawUVM()); 3006 Assert(VM_IS_EMT(pVM)); 3007 } 3005 3008 #endif 3006 3009
Note:
See TracChangeset
for help on using the changeset viewer.