VirtualBox

Ignore:
Timestamp:
Aug 25, 2016 5:19:22 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
110370
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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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