Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

HRESULT com::Shutdown (  ) 

Shuts down the COM runtime. Must be called on every thread before termination. No COM calls may be made after this method returns.

Definition at line 431 of file initterm.cpp.

References Assert, AssertComRC, and NOREF.

Referenced by COMBase::CleanupCOM(), and main().

    HRESULT rc = S_OK;

#if !defined (VBOX_WITH_XPCOM)


#else /* !defined (VBOX_WITH_XPCOM) */

    nsCOMPtr <nsIEventQueue> eventQ;
    rc = NS_GetMainEventQ (getter_AddRefs (eventQ));

        /* NS_ERROR_NOT_AVAILABLE seems to mean that
         * nsIEventQueue::StopAcceptingEvents() has been called (see
         * nsEventQueueService.cpp). We hope that this error code always means
         * just that in this case and assume that we're on the main thread
         * (it's a kind of unexpected behavior if a non-main thread ever calls
         * StopAcceptingEvents() on the main event queue). */

        PRBool isOnMainThread = PR_FALSE;
        if (NS_SUCCEEDED (rc))
            rc = eventQ->IsOnCurrentThread (&isOnMainThread);
            eventQ = nsnull; /* early release before shutdown */
            isOnMainThread = PR_TRUE;
            rc = NS_OK;

        if (NS_SUCCEEDED (rc) && isOnMainThread)
            /* only the main thread needs to uninitialize XPCOM and only if
             * init counter drops to zero */
            if (-- gXPCOMInitCount == 0)
                rc = NS_ShutdownXPCOM (nsnull);

                /* This is a thread initialized XPCOM and set gIsXPCOMInitialized to
                 * true. Reset it back to false. */
                bool wasInited = ASMAtomicXchgBool (&gIsXPCOMInitialized, false);
                Assert (wasInited == true);
                NOREF (wasInited);

#if defined (XPCOM_GLUE)

#endif /* !defined (VBOX_WITH_XPCOM) */

    AssertComRC (rc);

    return rc;

Generated by  Doxygen 1.6.0   Back to index