VirtualBox

Ignore:
Timestamp:
Sep 27, 2010 7:00:22 PM (14 years ago)
Author:
vboxsync
Message:

com/Guid: remove conversion operators to eliminate any compiler surprises. Caught one totally unexpected issue which was indirectly caused by the similar Bstr cleanup, as there still is a Bstr->Guid conversion and thus the Guid magic was triggered

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ProgressImpl.cpp

    r31625 r32780  
    66
    77/*
    8  * Copyright (C) 2006-2009 Oracle Corporation
     8 * Copyright (C) 2006-2010 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1919#include <iprt/types.h>
    2020
    21 #if defined (VBOX_WITH_XPCOM)
     21#if defined(VBOX_WITH_XPCOM)
    2222#include <nsIServiceManager.h>
    2323#include <nsIExceptionService.h>
    2424#include <nsCOMPtr.h>
    25 #endif /* defined (VBOX_WITH_XPCOM) */
     25#endif /* defined(VBOX_WITH_XPCOM) */
    2626
    2727#include "ProgressCombinedImpl.h"
     
    4646
    4747ProgressBase::ProgressBase()
    48 #if !defined (VBOX_COM_INPROC)
     48#if !defined(VBOX_COM_INPROC)
    4949    : mParent(NULL)
    5050#endif
     
    105105 */
    106106HRESULT ProgressBase::protectedInit(AutoInitSpan &aAutoInitSpan,
    107 #if !defined (VBOX_COM_INPROC)
     107#if !defined(VBOX_COM_INPROC)
    108108                                    VirtualBox *aParent,
    109109#endif
     
    113113{
    114114    /* Guarantees subclasses call this method at the proper time */
    115     NOREF (aAutoInitSpan);
     115    NOREF(aAutoInitSpan);
    116116
    117117    AutoCaller autoCaller(this);
    118118    AssertReturn(autoCaller.state() == InInit, E_FAIL);
    119119
    120 #if !defined (VBOX_COM_INPROC)
     120#if !defined(VBOX_COM_INPROC)
    121121    AssertReturn(aParent, E_INVALIDARG);
    122122#else
     
    126126    AssertReturn(aDescription, E_INVALIDARG);
    127127
    128 #if !defined (VBOX_COM_INPROC)
     128#if !defined(VBOX_COM_INPROC)
    129129    /* share parent weakly */
    130130    unconst(mParent) = aParent;
    131131#endif
    132132
    133 #if !defined (VBOX_COM_INPROC)
     133#if !defined(VBOX_COM_INPROC)
    134134    /* assign (and therefore addref) initiator only if it is not VirtualBox
    135135     * (to avoid cycling); otherwise mInitiator will remain null which means
     
    149149        mId.cloneTo(aId);
    150150
    151 #if !defined (VBOX_COM_INPROC)
     151#if !defined(VBOX_COM_INPROC)
    152152    /* add to the global collection of progress operations (note: after
    153153     * creating mId) */
     
    173173 * @param aAutoInitSpan AutoInitSpan object instantiated by a subclass.
    174174 */
    175 HRESULT ProgressBase::protectedInit (AutoInitSpan &aAutoInitSpan)
     175HRESULT ProgressBase::protectedInit(AutoInitSpan &aAutoInitSpan)
    176176{
    177177    /* Guarantees subclasses call this method at the proper time */
    178     NOREF (aAutoInitSpan);
     178    NOREF(aAutoInitSpan);
    179179
    180180    return S_OK;
     
    190190 * @note Using the mParent member after this method returns is forbidden.
    191191 */
    192 void ProgressBase::protectedUninit (AutoUninitSpan &aAutoUninitSpan)
     192void ProgressBase::protectedUninit(AutoUninitSpan &aAutoUninitSpan)
    193193{
    194194    /* release initiator (effective only if mInitiator has been assigned in
     
    196196    unconst(mInitiator).setNull();
    197197
    198 #if !defined (VBOX_COM_INPROC)
     198#if !defined(VBOX_COM_INPROC)
    199199    if (mParent)
    200200    {
    201201        /* remove the added progress on failure to complete the initialization */
    202202        if (aAutoUninitSpan.initFailed() && !mId.isEmpty())
    203             mParent->removeProgress (mId);
     203            mParent->removeProgress(mId.ref());
    204204
    205205        unconst(mParent) = NULL;
     
    211211/////////////////////////////////////////////////////////////////////////////
    212212
    213 STDMETHODIMP ProgressBase::COMGETTER(Id) (BSTR *aId)
     213STDMETHODIMP ProgressBase::COMGETTER(Id)(BSTR *aId)
    214214{
    215215    CheckComArgOutPointerValid(aId);
     
    224224}
    225225
    226 STDMETHODIMP ProgressBase::COMGETTER(Description) (BSTR *aDescription)
     226STDMETHODIMP ProgressBase::COMGETTER(Description)(BSTR *aDescription)
    227227{
    228228    CheckComArgOutPointerValid(aDescription);
     
    237237}
    238238
    239 STDMETHODIMP ProgressBase::COMGETTER(Initiator) (IUnknown **aInitiator)
     239STDMETHODIMP ProgressBase::COMGETTER(Initiator)(IUnknown **aInitiator)
    240240{
    241241    CheckComArgOutPointerValid(aInitiator);
     
    246246    /* mInitiator/mParent are constant during life time, no need to lock */
    247247
    248 #if !defined (VBOX_COM_INPROC)
     248#if !defined(VBOX_COM_INPROC)
    249249    if (mInitiator)
    250250        mInitiator.queryInterfaceTo(aInitiator);
     
    261261}
    262262
    263 STDMETHODIMP ProgressBase::COMGETTER(Cancelable) (BOOL *aCancelable)
     263STDMETHODIMP ProgressBase::COMGETTER(Cancelable)(BOOL *aCancelable)
    264264{
    265265    CheckComArgOutPointerValid(aCancelable);
     
    379379}
    380380
    381 STDMETHODIMP ProgressBase::COMGETTER(Completed) (BOOL *aCompleted)
     381STDMETHODIMP ProgressBase::COMGETTER(Completed)(BOOL *aCompleted)
    382382{
    383383    CheckComArgOutPointerValid(aCompleted);
     
    393393}
    394394
    395 STDMETHODIMP ProgressBase::COMGETTER(Canceled) (BOOL *aCanceled)
     395STDMETHODIMP ProgressBase::COMGETTER(Canceled)(BOOL *aCanceled)
    396396{
    397397    CheckComArgOutPointerValid(aCanceled);
     
    407407}
    408408
    409 STDMETHODIMP ProgressBase::COMGETTER(ResultCode) (LONG *aResultCode)
     409STDMETHODIMP ProgressBase::COMGETTER(ResultCode)(LONG *aResultCode)
    410410{
    411411    CheckComArgOutPointerValid(aResultCode);
     
    425425}
    426426
    427 STDMETHODIMP ProgressBase::COMGETTER(ErrorInfo) (IVirtualBoxErrorInfo **aErrorInfo)
     427STDMETHODIMP ProgressBase::COMGETTER(ErrorInfo)(IVirtualBoxErrorInfo **aErrorInfo)
    428428{
    429429    CheckComArgOutPointerValid(aErrorInfo);
     
    443443}
    444444
    445 STDMETHODIMP ProgressBase::COMGETTER(OperationCount) (ULONG *aOperationCount)
     445STDMETHODIMP ProgressBase::COMGETTER(OperationCount)(ULONG *aOperationCount)
    446446{
    447447    CheckComArgOutPointerValid(aOperationCount);
     
    457457}
    458458
    459 STDMETHODIMP ProgressBase::COMGETTER(Operation) (ULONG *aOperation)
     459STDMETHODIMP ProgressBase::COMGETTER(Operation)(ULONG *aOperation)
    460460{
    461461    CheckComArgOutPointerValid(aOperation);
     
    471471}
    472472
    473 STDMETHODIMP ProgressBase::COMGETTER(OperationDescription) (BSTR *aOperationDescription)
     473STDMETHODIMP ProgressBase::COMGETTER(OperationDescription)(BSTR *aOperationDescription)
    474474{
    475475    CheckComArgOutPointerValid(aOperationDescription);
     
    647647 * @param aId               See ProgressBase::init().
    648648 */
    649 HRESULT Progress::init (
    650 #if !defined (VBOX_COM_INPROC)
    651                         VirtualBox *aParent,
     649HRESULT Progress::init(
     650#if !defined(VBOX_COM_INPROC)
     651                       VirtualBox *aParent,
    652652#endif
    653                         IUnknown *aInitiator,
    654                         CBSTR aDescription,
    655                         BOOL aCancelable,
    656                         ULONG cOperations,
    657                         ULONG ulTotalOperationsWeight,
    658                         CBSTR bstrFirstOperationDescription,
    659                         ULONG ulFirstOperationWeight,
    660                         OUT_GUID aId /* = NULL */)
     653                       IUnknown *aInitiator,
     654                       CBSTR aDescription,
     655                       BOOL aCancelable,
     656                       ULONG cOperations,
     657                       ULONG ulTotalOperationsWeight,
     658                       CBSTR bstrFirstOperationDescription,
     659                       ULONG ulFirstOperationWeight,
     660                       OUT_GUID aId /* = NULL */)
    661661{
    662662    LogFlowThisFunc(("aDescription=\"%ls\", cOperations=%d, ulTotalOperationsWeight=%d, bstrFirstOperationDescription=\"%ls\", ulFirstOperationWeight=%d\n",
     
    676676    HRESULT rc = S_OK;
    677677
    678     rc = ProgressBase::protectedInit (autoInitSpan,
    679 #if !defined (VBOX_COM_INPROC)
    680                                       aParent,
     678    rc = ProgressBase::protectedInit(autoInitSpan,
     679#if !defined(VBOX_COM_INPROC)
     680                                     aParent,
    681681#endif
    682                                       aInitiator, aDescription, aId);
     682                                     aInitiator, aDescription, aId);
    683683    if (FAILED(rc)) return rc;
    684684
     
    693693    m_ulOperationPercent = 0;
    694694
    695     int vrc = RTSemEventMultiCreate (&mCompletedSem);
    696     ComAssertRCRet (vrc, E_FAIL);
    697 
    698     RTSemEventMultiReset (mCompletedSem);
     695    int vrc = RTSemEventMultiCreate(&mCompletedSem);
     696    ComAssertRCRet(vrc, E_FAIL);
     697
     698    RTSemEventMultiReset(mCompletedSem);
    699699
    700700    /* Confirm a successful initialization when it's the case */
     
    732732    HRESULT rc = S_OK;
    733733
    734     rc = ProgressBase::protectedInit (autoInitSpan);
     734    rc = ProgressBase::protectedInit(autoInitSpan);
    735735    if (FAILED(rc)) return rc;
    736736
     
    747747    m_ulOperationPercent = 0;
    748748
    749     int vrc = RTSemEventMultiCreate (&mCompletedSem);
    750     ComAssertRCRet (vrc, E_FAIL);
    751 
    752     RTSemEventMultiReset (mCompletedSem);
     749    int vrc = RTSemEventMultiCreate(&mCompletedSem);
     750    ComAssertRCRet(vrc, E_FAIL);
     751
     752    RTSemEventMultiReset(mCompletedSem);
    753753
    754754    /* Confirm a successful initialization when it's the case */
     
    776776    if (mWaitersCount > 0)
    777777    {
    778         LogFlow (("WARNING: There are still %d threads waiting for '%ls' completion!\n",
    779                   mWaitersCount, mDescription.raw()));
    780         RTSemEventMultiSignal (mCompletedSem);
    781     }
    782 
    783     RTSemEventMultiDestroy (mCompletedSem);
    784 
    785     ProgressBase::protectedUninit (autoUninitSpan);
     778        LogFlow(("WARNING: There are still %d threads waiting for '%ls' completion!\n",
     779                 mWaitersCount, mDescription.raw()));
     780        RTSemEventMultiSignal(mCompletedSem);
     781    }
     782
     783    RTSemEventMultiDestroy(mCompletedSem);
     784
     785    ProgressBase::protectedUninit(autoUninitSpan);
    786786}
    787787
     
    798798 *       calling this method will definitely freeze event processing.
    799799 */
    800 STDMETHODIMP Progress::WaitForCompletion (LONG aTimeout)
     800STDMETHODIMP Progress::WaitForCompletion(LONG aTimeout)
    801801{
    802802    LogFlowThisFuncEnter();
     
    10331033        /* try to import error info from the current thread */
    10341034
    1035 #if !defined (VBOX_WITH_XPCOM)
     1035#if !defined(VBOX_WITH_XPCOM)
    10361036
    10371037        ComPtr<IErrorInfo> err;
     
    10441044        }
    10451045
    1046 #else /* !defined (VBOX_WITH_XPCOM) */
     1046#else /* !defined(VBOX_WITH_XPCOM) */
    10471047
    10481048        nsCOMPtr<nsIExceptionService> es;
     
    10641064            }
    10651065        }
    1066 #endif /* !defined (VBOX_WITH_XPCOM) */
    1067 
    1068         AssertMsg (rc == S_OK, ("Couldn't get error info (rc=%08X) while trying "
    1069                                 "to set a failed result (%08X)!\n", rc, aResultCode));
     1066#endif /* !defined(VBOX_WITH_XPCOM) */
     1067
     1068        AssertMsg(rc == S_OK, ("Couldn't get error info (rc=%08X) while trying to set a failed result (%08X)!\n",
     1069                               rc, aResultCode));
    10701070    }
    10711071
     
    11161116    /* remove from the global collection of pending progress operations */
    11171117    if (mParent)
    1118         mParent->removeProgress (mId);
     1118        mParent->removeProgress(mId.ref());
    11191119#endif
    11201120
     
    11801180    ComObjPtr<VirtualBoxErrorInfo> errorInfo;
    11811181    HRESULT rc = errorInfo.createObject();
    1182     AssertComRC (rc);
     1182    AssertComRC(rc);
    11831183    if (SUCCEEDED(rc))
    11841184    {
     
    11901190    /* remove from the global collection of pending progress operations */
    11911191    if (mParent)
    1192         mParent->removeProgress (mId);
     1192        mParent->removeProgress(mId.ref());
    11931193#endif
    11941194
     
    12651265 * @param aId           See ProgressBase::init().
    12661266 */
    1267 HRESULT CombinedProgress::protectedInit (AutoInitSpan &aAutoInitSpan,
    1268 #if !defined (VBOX_COM_INPROC)
    1269                                          VirtualBox *aParent,
     1267HRESULT CombinedProgress::protectedInit(AutoInitSpan &aAutoInitSpan,
     1268#if !defined(VBOX_COM_INPROC)
     1269                                        VirtualBox *aParent,
    12701270#endif
    1271                                          IUnknown *aInitiator,
    1272                                          CBSTR aDescription, OUT_GUID aId)
     1271                                        IUnknown *aInitiator,
     1272                                        CBSTR aDescription, OUT_GUID aId)
    12731273{
    12741274    LogFlowThisFunc(("aDescription={%ls} mProgresses.size()=%d\n",
     
    12771277    HRESULT rc = S_OK;
    12781278
    1279     rc = ProgressBase::protectedInit (aAutoInitSpan,
    1280 #if !defined (VBOX_COM_INPROC)
    1281                                       aParent,
     1279    rc = ProgressBase::protectedInit(aAutoInitSpan,
     1280#if !defined(VBOX_COM_INPROC)
     1281                                     aParent,
    12821282#endif
    1283                                       aInitiator, aDescription, aId);
     1283                                     aInitiator, aDescription, aId);
    12841284    if (FAILED(rc)) return rc;
    12851285
     
    13361336 */
    13371337HRESULT CombinedProgress::init(
    1338 #if !defined (VBOX_COM_INPROC)
     1338#if !defined(VBOX_COM_INPROC)
    13391339                               VirtualBox *aParent,
    13401340#endif
     
    13541354
    13551355    HRESULT rc =  protectedInit(autoInitSpan,
    1356 #if !defined (VBOX_COM_INPROC)
     1356#if !defined(VBOX_COM_INPROC)
    13571357                                aParent,
    13581358#endif
     
    13851385    mProgresses.clear();
    13861386
    1387     ProgressBase::protectedUninit (autoUninitSpan);
     1387    ProgressBase::protectedUninit(autoUninitSpan);
    13881388}
    13891389
     
    14171417}
    14181418
    1419 STDMETHODIMP CombinedProgress::COMGETTER(Completed) (BOOL *aCompleted)
     1419STDMETHODIMP CombinedProgress::COMGETTER(Completed)(BOOL *aCompleted)
    14201420{
    14211421    CheckComArgOutPointerValid(aCompleted);
     
    14301430    if (FAILED(rc)) return rc;
    14311431
    1432     return ProgressBase::COMGETTER(Completed) (aCompleted);
    1433 }
    1434 
    1435 STDMETHODIMP CombinedProgress::COMGETTER(Canceled) (BOOL *aCanceled)
     1432    return ProgressBase::COMGETTER(Completed)(aCompleted);
     1433}
     1434
     1435STDMETHODIMP CombinedProgress::COMGETTER(Canceled)(BOOL *aCanceled)
    14361436{
    14371437    CheckComArgOutPointerValid(aCanceled);
     
    14461446    if (FAILED(rc)) return rc;
    14471447
    1448     return ProgressBase::COMGETTER(Canceled) (aCanceled);
    1449 }
    1450 
    1451 STDMETHODIMP CombinedProgress::COMGETTER(ResultCode) (LONG *aResultCode)
     1448    return ProgressBase::COMGETTER(Canceled)(aCanceled);
     1449}
     1450
     1451STDMETHODIMP CombinedProgress::COMGETTER(ResultCode)(LONG *aResultCode)
    14521452{
    14531453    CheckComArgOutPointerValid(aResultCode);
     
    14621462    if (FAILED(rc)) return rc;
    14631463
    1464     return ProgressBase::COMGETTER(ResultCode) (aResultCode);
    1465 }
    1466 
    1467 STDMETHODIMP CombinedProgress::COMGETTER(ErrorInfo) (IVirtualBoxErrorInfo **aErrorInfo)
     1464    return ProgressBase::COMGETTER(ResultCode)(aResultCode);
     1465}
     1466
     1467STDMETHODIMP CombinedProgress::COMGETTER(ErrorInfo)(IVirtualBoxErrorInfo **aErrorInfo)
    14681468{
    14691469    CheckComArgOutPointerValid(aErrorInfo);
     
    14781478    if (FAILED(rc)) return rc;
    14791479
    1480     return ProgressBase::COMGETTER(ErrorInfo) (aErrorInfo);
    1481 }
    1482 
    1483 STDMETHODIMP CombinedProgress::COMGETTER(Operation) (ULONG *aOperation)
     1480    return ProgressBase::COMGETTER(ErrorInfo)(aErrorInfo);
     1481}
     1482
     1483STDMETHODIMP CombinedProgress::COMGETTER(Operation)(ULONG *aOperation)
    14841484{
    14851485    CheckComArgOutPointerValid(aOperation);
     
    14941494    if (FAILED(rc)) return rc;
    14951495
    1496     return ProgressBase::COMGETTER(Operation) (aOperation);
    1497 }
    1498 
    1499 STDMETHODIMP CombinedProgress::COMGETTER(OperationDescription) (BSTR *aOperationDescription)
     1496    return ProgressBase::COMGETTER(Operation)(aOperation);
     1497}
     1498
     1499STDMETHODIMP CombinedProgress::COMGETTER(OperationDescription)(BSTR *aOperationDescription)
    15001500{
    15011501    CheckComArgOutPointerValid(aOperationDescription);
     
    15101510    if (FAILED(rc)) return rc;
    15111511
    1512     return ProgressBase::COMGETTER(OperationDescription) (aOperationDescription);
     1512    return ProgressBase::COMGETTER(OperationDescription)(aOperationDescription);
    15131513}
    15141514
     
    15261526    if (FAILED(rc)) return rc;
    15271527
    1528     return ProgressBase::COMGETTER(OperationPercent) (aOperationPercent);
     1528    return ProgressBase::COMGETTER(OperationPercent)(aOperationPercent);
    15291529}
    15301530
     
    15531553 *       calling this method will definitely freeze event processing.
    15541554 */
    1555 STDMETHODIMP CombinedProgress::WaitForCompletion (LONG aTimeout)
     1555STDMETHODIMP CombinedProgress::WaitForCompletion(LONG aTimeout)
    15561556{
    15571557    LogFlowThisFuncEnter();
     
    16041604 *       calling this method will definitely freeze event processing.
    16051605 */
    1606 STDMETHODIMP CombinedProgress::WaitForOperationCompletion (ULONG aOperation, LONG aTimeout)
     1606STDMETHODIMP CombinedProgress::WaitForOperationCompletion(ULONG aOperation, LONG aTimeout)
    16071607{
    16081608    LogFlowThisFuncEnter();
     
    17561756            if (FAILED(mResultCode))
    17571757            {
    1758                 rc = progress->COMGETTER(ErrorInfo) (mErrorInfo.asOutParam());
     1758                rc = progress->COMGETTER(ErrorInfo)(mErrorInfo.asOutParam());
    17591759                if (FAILED(rc))
    17601760                    return rc;
     
    17681768            {
    17691769                ULONG opCount = 0;
    1770                 rc = progress->COMGETTER(OperationCount) (&opCount);
     1770                rc = progress->COMGETTER(OperationCount)(&opCount);
    17711771                if (FAILED(rc))
    17721772                    return rc;
     
    17841784    while (fCompleted && !mCompleted);
    17851785
    1786     rc = progress->COMGETTER(OperationPercent) (&m_ulOperationPercent);
     1786    rc = progress->COMGETTER(OperationPercent)(&m_ulOperationPercent);
    17871787    if (SUCCEEDED(rc))
    17881788    {
    17891789        ULONG operation = 0;
    1790         rc = progress->COMGETTER(Operation) (&operation);
     1790        rc = progress->COMGETTER(Operation)(&operation);
    17911791        if (SUCCEEDED(rc) && mCompletedOperations + operation > m_ulCurrentOperation)
    17921792        {
    17931793            m_ulCurrentOperation = mCompletedOperations + operation;
    1794             rc = progress->COMGETTER(OperationDescription) (
    1795                 m_bstrOperationDescription.asOutParam());
     1794            rc = progress->COMGETTER(OperationDescription)(m_bstrOperationDescription.asOutParam());
    17961795        }
    17971796    }
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