vbox/src/VBox/Main/src-client/GuestSessionImpl.cpp
/* Does not do locking; caller is responsible for that! */
Does not do locking; caller is responsible for that!
Does not do locking ; caller is responsible for that!
int GuestSession::i_setSessionStatus(GuestSessionStatus_T sessionStatus, int sessionRc)
{
    LogFlowThisFunc(("oldStatus=%RU32, newStatus=%RU32, sessionRc=%Rrc\n",
                     mData.mStatus, sessionStatus, sessionRc));
    if (sessionStatus == GuestSessionStatus_Error)
    {
        AssertMsg(RT_FAILURE(sessionRc), ("Guest rc must be an error (%Rrc)\n", sessionRc));
        AssertMsg(RT_SUCCESS(mData.mRC), ("Guest rc already set (to %Rrc)\n", mData.mRC));
    }
    else
        AssertMsg(RT_SUCCESS(sessionRc), ("Guest rc must not be an error (%Rrc)\n", sessionRc));
    if (mData.mStatus != sessionStatus)
    {
        mData.mStatus = sessionStatus;
        mData.mRC     = sessionRc;
        ComObjPtr<VirtualBoxErrorInfo> errorInfo;
        HRESULT hr = errorInfo.createObject();
        ComAssertComRC(hr);
        int rc2 = errorInfo->initEx(VBOX_E_IPRT_ERROR, sessionRc,
                                    COM_IIDOF(IGuestSession), getComponentName(),
                                    i_guestErrorToString(sessionRc));
        AssertRC(rc2);
        fireGuestSessionStateChangedEvent(mEventSource, this,
                                          mData.mSession.mID, sessionStatus, errorInfo);
    }
    return VINF_SUCCESS;
}
int GuestSession :: i_setSessionStatus ( GuestSessionStatus_T sessionStatus , int sessionRc ) { LogFlowThisFunc ( ( " \n " , mData . mStatus , sessionStatus , sessionRc ) ) ; if ( sessionStatus == GuestSessionStatus_Error ) { AssertMsg ( RT_FAILURE ( sessionRc ) , ( " \n " , sessionRc ) ) ; AssertMsg ( RT_SUCCESS ( mData . mRC ) , ( " \n " , mData . mRC ) ) ; } else AssertMsg ( RT_SUCCESS ( sessionRc ) , ( " \n " , sessionRc ) ) ; if ( mData . mStatus != sessionStatus ) { mData . mStatus = sessionStatus ; mData . mRC = sessionRc ; ComObjPtr < VirtualBoxErrorInfo > errorInfo ; HRESULT hr = errorInfo . createObject ( ) ; ComAssertComRC ( hr ) ; int rc2 = errorInfo -> initEx ( VBOX_E_IPRT_ERROR , sessionRc , COM_IIDOF ( IGuestSession ) , getComponentName ( ) , i_guestErrorToString ( sessionRc ) ) ; AssertRC ( rc2 ) ; fireGuestSessionStateChangedEvent ( mEventSource , this , mData . mSession . mID , sessionStatus , errorInfo ) ; } return VINF_SUCCESS ; }
Does not do locking; caller is responsible for that!
Does not do locking ; caller is responsible for that!
/* Do not allow overwriting an already set error. If this happens
         * this means we forgot some error checking/locking somewhere. */