VirtualBox

Changeset 85251 in vbox


Ignore:
Timestamp:
Jul 11, 2020 11:17:17 PM (4 years ago)
Author:
vboxsync
Message:

Main/ProgressImpl: Better solution to the LONG aResultCode issue of notifyComplete(). bugref:9790

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ProgressImpl.h

    r82968 r85251  
    235235
    236236    // internal helper methods
     237    HRESULT i_notifyCompleteWorker(HRESULT aResultCode, const ComPtr<IVirtualBoxErrorInfo> &aErrorInfo);
    237238    double i_calcTotalPercent();
    238239    void i_checkForAutomaticTimeout(void);
  • trunk/src/VBox/Main/src-all/ProgressImpl.cpp

    r85214 r85251  
    369369    }
    370370
    371     return notifyComplete((LONG)aResultCode, errorInfo);
     371    return i_notifyCompleteWorker(aResultCode, errorInfo);
    372372}
    373373
     
    413413    errorInfo->init(aResultCode, aIID, pcszComponent, text);
    414414
    415     return notifyComplete((LONG)aResultCode, errorInfo);
     415    return i_notifyCompleteWorker(aResultCode, errorInfo);
    416416}
    417417
     
    460460    errorInfo->initEx(aResultCode, vrc, aIID, pszComponent, text);
    461461
    462     return notifyComplete((LONG)aResultCode, errorInfo);
     462    return i_notifyCompleteWorker(aResultCode, errorInfo);
    463463}
    464464
     
    11121112HRESULT Progress::notifyComplete(LONG aResultCode, const ComPtr<IVirtualBoxErrorInfo> &aErrorInfo)
    11131113{
    1114     HRESULT hrcOperation = (HRESULT)aResultCode; /* XPCOM has an unsigned HRESULT, upsetting Clang 11 wrt sign conv. */
    1115     LogThisFunc(("hrcOperation=%Rhrc\n", hrcOperation));
     1114    return i_notifyCompleteWorker((HRESULT)aResultCode, aErrorInfo);
     1115}
     1116
     1117
     1118// private internal helpers
     1119/////////////////////////////////////////////////////////////////////////////
     1120
     1121/**
     1122 * Marks the operation as complete and attaches full error info.
     1123 *
     1124 * This is where the actual work is done, the related methods all end up here.
     1125 *
     1126 * @param aResultCode       Operation result (error) code, must not be S_OK.
     1127 * @param aErrorInfo        List of arguments for the format string.
     1128 *
     1129 * @note This is just notifyComplete with the correct aResultCode type.
     1130 */
     1131HRESULT Progress::i_notifyCompleteWorker(HRESULT aResultCode, const ComPtr<IVirtualBoxErrorInfo> &aErrorInfo)
     1132{
     1133    LogThisFunc(("aResultCode=%Rhrc\n", aResultCode));
    11161134    /* on failure we expect error info, on success there must be none */
    1117     AssertMsg(FAILED(hrcOperation) ^ aErrorInfo.isNull(),
    1118               ("No error info but trying to set a failed result (%08X)!\n",
    1119                hrcOperation));
     1135    AssertMsg(FAILED(aResultCode) ^ aErrorInfo.isNull(),
     1136              ("No error info but trying to set a failed result (%08X/%Rhrc)!\n", aResultCode, aResultCode));
    11201137
    11211138    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    11231140    AssertReturn(mCompleted == FALSE, E_FAIL);
    11241141
    1125     if (mCanceled && SUCCEEDED(hrcOperation))
    1126         hrcOperation = E_FAIL;
     1142    if (mCanceled && SUCCEEDED(aResultCode))
     1143        aResultCode = E_FAIL;
    11271144
    11281145    mCompleted = TRUE;
    1129     mResultCode = hrcOperation;
    1130     if (SUCCEEDED(hrcOperation))
     1146    mResultCode = aResultCode;
     1147    if (SUCCEEDED(aResultCode))
    11311148    {
    11321149        m_ulCurrentOperation = m_cOperations - 1; /* last operation */
     
    11501167}
    11511168
    1152 
    1153 // private internal helpers
    1154 /////////////////////////////////////////////////////////////////////////////
    1155 
    11561169/**
    11571170 * Internal helper to compute the total percent value based on the member values and
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette