Changeset 85214 in vbox
- Timestamp:
- Jul 11, 2020 1:04:06 PM (4 years ago)
- File:
-
- 1 edited
-
trunk/src/VBox/Main/src-all/ProgressImpl.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-all/ProgressImpl.cpp
r82968 r85214 369 369 } 370 370 371 return notifyComplete( aResultCode, errorInfo);371 return notifyComplete((LONG)aResultCode, errorInfo); 372 372 } 373 373 … … 413 413 errorInfo->init(aResultCode, aIID, pcszComponent, text); 414 414 415 return notifyComplete( aResultCode, errorInfo);415 return notifyComplete((LONG)aResultCode, errorInfo); 416 416 } 417 417 … … 460 460 errorInfo->initEx(aResultCode, vrc, aIID, pszComponent, text); 461 461 462 return notifyComplete( aResultCode, errorInfo);462 return notifyComplete((LONG)aResultCode, errorInfo); 463 463 } 464 464 … … 656 656 return setError(E_FAIL, tr("Result code is not available, operation is still in progress")); 657 657 658 *aResultCode = mResultCode;658 *aResultCode = (LONG)mResultCode; 659 659 660 660 return S_OK; … … 766 766 767 767 /* if we're already completed, take a shortcut */ 768 if (!mCompleted) 769 { 770 int vrc = VINF_SUCCESS; 771 bool fForever = aTimeout < 0; 772 int64_t timeLeft = aTimeout; 773 int64_t lastTime = RTTimeMilliTS(); 774 775 while (!mCompleted && (fForever || timeLeft > 0)) 768 if (!mCompleted && aTimeout != 0) 769 { 770 RTMSINTERVAL cMsWait = aTimeout < 0 ? RT_INDEFINITE_WAIT : (RTMSINTERVAL)aTimeout; 771 uint64_t msLast = aTimeout < 0 ? 0 : RTTimeMilliTS(); 772 773 for (;;) 776 774 { 777 775 mWaitersCount++; 778 776 alock.release(); 779 vrc = RTSemEventMultiWait(mCompletedSem, 780 fForever ? RT_INDEFINITE_WAIT : (RTMSINTERVAL)timeLeft); 777 int vrc = RTSemEventMultiWait(mCompletedSem, cMsWait); 781 778 alock.acquire(); 782 779 mWaitersCount--; … … 787 784 788 785 if (RT_FAILURE(vrc) && vrc != VERR_TIMEOUT) 786 return setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Failed to wait for the task completion (%Rrc)"), vrc); 787 788 if (mCompleted) 789 789 break; 790 790 791 if ( !fForever)791 if (aTimeout >= 0) 792 792 { 793 int64_t now = RTTimeMilliTS(); 794 timeLeft -= now - lastTime; 795 lastTime = now; 793 uint64_t msNow = RTTimeMilliTS(); 794 uint64_t cMsElapsed = msNow - msLast; 795 if (cMsWait <= cMsElapsed) 796 break; 797 cMsWait -= (RTMSINTERVAL)cMsElapsed; 798 msLast = msNow; 796 799 } 797 800 } 798 799 if (RT_FAILURE(vrc) && vrc != VERR_TIMEOUT)800 return setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Failed to wait for the task completion (%Rrc)"), vrc);801 801 } 802 802 803 803 LogFlowThisFuncLeave(); 804 805 804 return S_OK; 806 805 } … … 825 824 * then take a shortcut */ 826 825 if ( !mCompleted 827 && aOperation >= m_ulCurrentOperation) 828 { 829 int vrc = VINF_SUCCESS; 830 bool fForever = aTimeout < 0; 831 int64_t timeLeft = aTimeout; 832 int64_t lastTime = RTTimeMilliTS(); 833 834 while ( !mCompleted && aOperation >= m_ulCurrentOperation 835 && (fForever || timeLeft > 0)) 826 && aOperation >= m_ulCurrentOperation 827 && aTimeout != 0) 828 { 829 RTMSINTERVAL cMsWait = aTimeout < 0 ? RT_INDEFINITE_WAIT : (RTMSINTERVAL)aTimeout; 830 uint64_t msLast = aTimeout < 0 ? 0 : RTTimeMilliTS(); 831 832 for (;;) 836 833 { 837 834 mWaitersCount ++; 838 835 alock.release(); 839 vrc = RTSemEventMultiWait(mCompletedSem, 840 fForever ? RT_INDEFINITE_WAIT : (unsigned) timeLeft); 836 int vrc = RTSemEventMultiWait(mCompletedSem, cMsWait); 841 837 alock.acquire(); 842 838 mWaitersCount--; … … 847 843 848 844 if (RT_FAILURE(vrc) && vrc != VERR_TIMEOUT) 845 return setErrorBoth(E_FAIL, vrc, tr("Failed to wait for the operation completion (%Rrc)"), vrc); 846 847 if (mCompleted || aOperation >= m_ulCurrentOperation) 849 848 break; 850 849 851 if ( !fForever)850 if (aTimeout >= 0) 852 851 { 853 int64_t now = RTTimeMilliTS(); 854 timeLeft -= now - lastTime; 855 lastTime = now; 852 uint64_t msNow = RTTimeMilliTS(); 853 uint64_t cMsElapsed = msNow - msLast; 854 if (cMsWait <= cMsElapsed) 855 break; 856 cMsWait -= (RTMSINTERVAL)cMsElapsed; 857 msLast = msNow; 856 858 } 857 859 } 858 859 if (RT_FAILURE(vrc) && vrc != VERR_TIMEOUT)860 return setErrorBoth(E_FAIL, vrc, tr("Failed to wait for the operation completion (%Rrc)"), vrc);861 860 } 862 861 863 862 LogFlowThisFuncLeave(); 864 865 863 return S_OK; 866 864 } … … 913 911 ULONG actualPercent = 0; 914 912 getPercent(&actualPercent); 915 fireProgressPercentageChangedEvent(pEventSource, mId.toUtf16().raw(), actualPercent);913 fireProgressPercentageChangedEvent(pEventSource, mId.toUtf16().raw(), (LONG)actualPercent); 916 914 } 917 915 … … 1026 1024 rc = aProgressOther->COMGETTER(ResultCode)(&iRc); 1027 1025 if (FAILED(rc)) return rc; 1028 if (FAILED( iRc))1026 if (FAILED((HRESULT)iRc)) 1029 1027 { 1030 1028 setError(ProgressErrorInfo(aProgressOther)); 1031 rc = iRc;1029 rc = (HRESULT)iRc; 1032 1030 } 1033 1031 … … 1070 1068 ULONG actualPercent = 0; 1071 1069 getPercent(&actualPercent); 1072 fireProgressPercentageChangedEvent(pEventSource, mId.toUtf16().raw(), actualPercent);1070 fireProgressPercentageChangedEvent(pEventSource, mId.toUtf16().raw(), (LONG)actualPercent); 1073 1071 1074 1072 return S_OK; … … 1114 1112 HRESULT Progress::notifyComplete(LONG aResultCode, const ComPtr<IVirtualBoxErrorInfo> &aErrorInfo) 1115 1113 { 1116 LogThisFunc(("aResultCode=%d\n", aResultCode)); 1114 HRESULT hrcOperation = (HRESULT)aResultCode; /* XPCOM has an unsigned HRESULT, upsetting Clang 11 wrt sign conv. */ 1115 LogThisFunc(("hrcOperation=%Rhrc\n", hrcOperation)); 1117 1116 /* on failure we expect error info, on success there must be none */ 1118 AssertMsg(FAILED( aResultCode) ^ aErrorInfo.isNull(),1117 AssertMsg(FAILED(hrcOperation) ^ aErrorInfo.isNull(), 1119 1118 ("No error info but trying to set a failed result (%08X)!\n", 1120 aResultCode));1119 hrcOperation)); 1121 1120 1122 1121 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 1124 1123 AssertReturn(mCompleted == FALSE, E_FAIL); 1125 1124 1126 if (mCanceled && SUCCEEDED( aResultCode))1127 aResultCode= E_FAIL;1125 if (mCanceled && SUCCEEDED(hrcOperation)) 1126 hrcOperation = E_FAIL; 1128 1127 1129 1128 mCompleted = TRUE; 1130 mResultCode = aResultCode;1131 if (SUCCEEDED( aResultCode))1129 mResultCode = hrcOperation; 1130 if (SUCCEEDED(hrcOperation)) 1132 1131 { 1133 1132 m_ulCurrentOperation = m_cOperations - 1; /* last operation */
Note:
See TracChangeset
for help on using the changeset viewer.

