Changeset 94926 in vbox for trunk/src/VBox/Main/src-client/VirtualBoxClientImpl.cpp
- Timestamp:
- May 8, 2022 7:57:08 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 151334
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/VirtualBoxClientImpl.cpp
r93115 r94926 141 141 HRESULT VirtualBoxClient::FinalConstruct() 142 142 { 143 HRESULT rc = init();143 HRESULT hrc = init(); 144 144 BaseFinalConstruct(); 145 return rc;145 return hrc; 146 146 } 147 147 … … 177 177 * unhelpful ones which cause us a lot of grief with troubleshooting. */ 178 178 179 HRESULT rc = S_OK;179 HRESULT hrc = S_OK; 180 180 try 181 181 { … … 186 186 mData.m_SemEvWatcher = NIL_RTSEMEVENT; 187 187 188 rc = mData.m_pVirtualBox.createLocalObject(CLSID_VirtualBox);189 if (FAILED( rc))188 hrc = mData.m_pVirtualBox.createLocalObject(CLSID_VirtualBox); 189 if (FAILED(hrc)) 190 190 #ifdef RT_OS_WINDOWS 191 throw i_investigateVirtualBoxObjectCreationFailure( rc);191 throw i_investigateVirtualBoxObjectCreationFailure(hrc); 192 192 #else 193 throw rc;193 throw hrc; 194 194 #endif 195 195 196 196 /* VirtualBox error return is postponed to method calls, fetch it. */ 197 197 ULONG rev; 198 rc = mData.m_pVirtualBox->COMGETTER(Revision)(&rev);199 if (FAILED( rc))200 throw rc;201 202 rc = unconst(mData.m_pEventSource).createObject();203 AssertComRCThrow( rc, setError(rc, "Could not create EventSource for VirtualBoxClient"));204 rc = mData.m_pEventSource->init();205 AssertComRCThrow( rc, setError(rc, "Could not initialize EventSource for VirtualBoxClient"));198 hrc = mData.m_pVirtualBox->COMGETTER(Revision)(&rev); 199 if (FAILED(hrc)) 200 throw hrc; 201 202 hrc = unconst(mData.m_pEventSource).createObject(); 203 AssertComRCThrow(hrc, setError(hrc, "Could not create EventSource for VirtualBoxClient")); 204 hrc = mData.m_pEventSource->init(); 205 AssertComRCThrow(hrc, setError(hrc, "Could not initialize EventSource for VirtualBoxClient")); 206 206 207 207 /* HACK ALERT! This is for DllCanUnloadNow(). */ … … 226 226 if (RT_SUCCESS(vrc)) 227 227 { 228 rc = i_reloadApiLanguage();229 if (SUCCEEDED( rc))228 hrc = i_reloadApiLanguage(); 229 if (SUCCEEDED(hrc)) 230 230 i_registerEventListener(); /* for updates */ 231 231 else 232 LogRelFunc(("i_reloadApiLanguage failed: %Rhrc\n", rc));232 LogRelFunc(("i_reloadApiLanguage failed: %Rhrc\n", hrc)); 233 233 } 234 234 else … … 245 245 { 246 246 mData.m_SemEvWatcher = NIL_RTSEMEVENT; 247 AssertRCStmt(vrc, throw setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Failed to create semaphore ( rc=%Rrc)"), vrc));247 AssertRCStmt(vrc, throw setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Failed to create semaphore (vrc=%Rrc)"), vrc)); 248 248 } 249 249 … … 254 254 RTSemEventDestroy(mData.m_SemEvWatcher); 255 255 mData.m_SemEvWatcher = NIL_RTSEMEVENT; 256 AssertRCStmt(vrc, throw setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Failed to create watcher thread ( rc=%Rrc)"), vrc));256 AssertRCStmt(vrc, throw setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Failed to create watcher thread (vrc=%Rrc)"), vrc)); 257 257 } 258 258 } … … 260 260 { 261 261 /* we assume that error info is set by the thrower */ 262 rc = err;262 hrc = err; 263 263 } 264 264 catch (...) 265 265 { 266 rc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);266 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); 267 267 } 268 268 269 269 /* Confirm a successful initialization when it's the case. Must be last, 270 270 * as on failure it will uninitialize the object. */ 271 if (SUCCEEDED( rc))271 if (SUCCEEDED(hrc)) 272 272 autoInitSpan.setSucceeded(); 273 273 else 274 autoInitSpan.setFailed( rc);275 276 LogFlowThisFunc((" rc=%Rhrc\n",rc));274 autoInitSpan.setFailed(hrc); 275 276 LogFlowThisFunc(("hrc=%Rhrc\n", hrc)); 277 277 LogFlowThisFuncLeave(); 278 278 /* Unconditionally return success, because the error return is delayed to … … 641 641 /* this is not stored in this object, no need to lock */ 642 642 ComPtr<ISession> pSession; 643 HRESULT rc = pSession.createInprocObject(CLSID_Session);644 if (SUCCEEDED( rc))643 HRESULT hrc = pSession.createInprocObject(CLSID_Session); 644 if (SUCCEEDED(hrc)) 645 645 aSession = pSession; 646 return rc;646 return hrc; 647 647 } 648 648 … … 672 672 { 673 673 BOOL fAccessible = FALSE; 674 HRESULT rc = aMachine->COMGETTER(Accessible)(&fAccessible);675 if (FAILED( rc))676 return setError( rc, tr("Could not check the accessibility status of the VM"));674 HRESULT hrc = aMachine->COMGETTER(Accessible)(&fAccessible); 675 if (FAILED(hrc)) 676 return setError(hrc, tr("Could not check the accessibility status of the VM")); 677 677 else if (!fAccessible) 678 678 { 679 679 ComPtr<IVirtualBoxErrorInfo> pAccessError; 680 rc = aMachine->COMGETTER(AccessError)(pAccessError.asOutParam());681 if (FAILED( rc))682 return setError( rc, tr("Could not get the access error message of the VM"));680 hrc = aMachine->COMGETTER(AccessError)(pAccessError.asOutParam()); 681 if (FAILED(hrc)) 682 return setError(hrc, tr("Could not get the access error message of the VM")); 683 683 else 684 684 { … … 705 705 RTSEMEVENT sem = pThis->mData.m_SemEvWatcher; 706 706 RTMSINTERVAL cMillies = VBOXCLIENT_DEFAULT_INTERVAL; 707 int vrc;708 707 709 708 /* The likelihood of early crashes are high, so start with a short wait. */ 710 vrc = RTSemEventWait(sem, cMillies / 2);709 int vrc = RTSemEventWait(sem, cMillies / 2); 711 710 712 711 /* As long as the waiting times out keep retrying the wait. */ … … 714 713 { 715 714 { 716 HRESULT rc = S_OK;715 HRESULT hrc = S_OK; 717 716 ComPtr<IVirtualBox> pV; 718 717 { … … 723 722 { 724 723 ULONG rev; 725 rc = pV->COMGETTER(Revision)(&rev);726 if (FAILED_DEAD_INTERFACE( rc))724 hrc = pV->COMGETTER(Revision)(&rev); 725 if (FAILED_DEAD_INTERFACE(hrc)) 727 726 { 728 LogRel(("VirtualBoxClient: detected unresponsive VBoxSVC ( rc=%Rhrc)\n",rc));727 LogRel(("VirtualBoxClient: detected unresponsive VBoxSVC (hrc=%Rhrc)\n", hrc)); 729 728 { 730 729 AutoWriteLock alock(pThis COMMA_LOCKVAL_SRC_POS); … … 744 743 ComPtr<IVirtualBox> pVirtualBox; 745 744 ComPtr<IToken> pToken; 746 rc = pVirtualBox.createLocalObject(CLSID_VirtualBox);747 if (FAILED( rc))745 hrc = pVirtualBox.createLocalObject(CLSID_VirtualBox); 746 if (FAILED(hrc)) 748 747 cMillies = 3 * VBOXCLIENT_DEFAULT_INTERVAL; 749 748 else 750 749 { 751 LogRel(("VirtualBoxClient: detected working VBoxSVC ( rc=%Rhrc)\n",rc));750 LogRel(("VirtualBoxClient: detected working VBoxSVC (hrc=%Rhrc)\n", hrc)); 752 751 { 753 752 AutoWriteLock alock(pThis COMMA_LOCKVAL_SRC_POS); … … 779 778 return S_OK; 780 779 781 HRESULT rc = mData.m_pVBoxTranslator->loadLanguage(mData.m_pVirtualBox);782 if (FAILED( rc))783 setError( rc, tr("Failed to load user language instance"));784 return rc;780 HRESULT hrc = mData.m_pVBoxTranslator->loadLanguage(mData.m_pVirtualBox); 781 if (FAILED(hrc)) 782 setError(hrc, tr("Failed to load user language instance")); 783 return hrc; 785 784 } 786 785 787 786 HRESULT VirtualBoxClient::i_registerEventListener() 788 787 { 789 HRESULT rc = mData.m_pVirtualBox->COMGETTER(EventSource)(mData.m_pVBoxEventSource.asOutParam());790 if (SUCCEEDED( rc))788 HRESULT hrc = mData.m_pVirtualBox->COMGETTER(EventSource)(mData.m_pVBoxEventSource.asOutParam()); 789 if (SUCCEEDED(hrc)) 791 790 { 792 791 ComObjPtr<VBoxEventListenerImpl> pVBoxListener; … … 796 795 com::SafeArray<VBoxEventType_T> eventTypes; 797 796 eventTypes.push_back(VBoxEventType_OnLanguageChanged); 798 rc = mData.m_pVBoxEventSource->RegisterListener(pVBoxListener, ComSafeArrayAsInParam(eventTypes), true);799 if (FAILED( rc))800 { 801 rc = setError(rc, tr("Failed to register listener"));797 hrc = mData.m_pVBoxEventSource->RegisterListener(pVBoxListener, ComSafeArrayAsInParam(eventTypes), true); 798 if (FAILED(hrc)) 799 { 800 hrc = setError(hrc, tr("Failed to register listener")); 802 801 mData.m_pVBoxEventListener.setNull(); 803 802 mData.m_pVBoxEventSource.setNull(); … … 805 804 } 806 805 else 807 rc = setError(rc, tr("Failed to get event source from VirtualBox"));808 return rc;806 hrc = setError(hrc, tr("Failed to get event source from VirtualBox")); 807 return hrc; 809 808 } 810 809
Note:
See TracChangeset
for help on using the changeset viewer.