VirtualBox

Changeset 63643 in vbox


Ignore:
Timestamp:
Aug 25, 2016 5:19:22 PM (8 years ago)
Author:
vboxsync
Message:

VBoxC: VirtualBoxClient need to go away ASAP nobody is using it any more because it is patently unsafe to destroy the instance from DllMain/detach. This is a uttly gross hack, but it seems to cure the GUI issue for me.

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

Legend:

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

    r63331 r63643  
    6767#undef DECLARE_CLASSFACTORY_SINGLETON
    6868#define DECLARE_CLASSFACTORY_SINGLETON(obj) DECLARE_CLASSFACTORY_EX(CMyComClassFactorySingleton<obj>)
     69
     70/**
     71 * @todo r=bird: This CMyComClassFactorySingleton stuff is probably obsoleted by
     72 *                microatl.h? Right?
     73 */
    6974
    7075template <class T>
  • trunk/src/VBox/Main/include/VirtualBoxClientImpl.h

    r63639 r63643  
    4747    HRESULT init();
    4848    void uninit();
     49
     50#ifdef RT_OS_WINDOWS
     51    /* HACK ALERT! Implemented in dllmain.cpp. */
     52    ULONG InternalRelease();
     53#endif
    4954
    5055private:
  • trunk/src/VBox/Main/src-client/win/dllmain.cpp

    r63641 r63643  
    117117}
    118118
     119
     120#ifdef RT_OS_WINDOWS
     121/*
     122 * HACK ALERT! Really ugly trick to make the VirtualBoxClient object go away
     123 *             when nobody uses it anymore.  This is to prevent its uninit()
     124 *             method from accessing IVirtualBox and similar proxy stubs after
     125 *             COM has been officially shut down.
     126 *
     127 *             It is simply TOO LATE to destroy the client object from DllMain/detach!
     128 *
     129 *             This hack ASSUMES ObjectMap order.
     130 *             This hack is subject to a re-instantiation race.
     131 */
     132ULONG VirtualBoxClient::InternalRelease()
     133{
     134    ULONG cRefs = VirtualBoxClientWrap::InternalRelease();
     135# ifdef DEBUG_bird
     136    char szMsg[64];
     137    RTStrPrintf(szMsg, sizeof(szMsg), "VirtualBoxClient: cRefs=%d\n", cRefs);
     138    OutputDebugStringA(szMsg);
     139# endif
     140# if 1 /* enable ugly hack */
     141    if (cRefs == 1)
     142    {
     143        /* Make the factory to drop its reference. */
     144        if (ObjectMap[1].pCF)
     145        {
     146            InternalAddRef();
     147
     148            CMyComClassFactorySingleton<VirtualBoxClient> *pFactory;
     149            pFactory = dynamic_cast<CMyComClassFactorySingleton<VirtualBoxClient> *>(ObjectMap[1].pCF);
     150            Assert(pFactory);
     151            if (pFactory)
     152            {
     153                IUnknown *pUnknown = pFactory->m_spObj;
     154                pFactory->m_spObj = NULL;
     155                if (pUnknown)
     156                    pUnknown->Release();
     157            }
     158
     159            cRefs = VirtualBoxClientWrap::InternalRelease();
     160        }
     161    }
     162# endif
     163    return cRefs;
     164}
     165#endif
     166
     167
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