VirtualBox

Changeset 60865 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 6, 2016 2:43:04 PM (9 years ago)
Author:
vboxsync
Message:

Never use static instances of CComModule as it messes up the log filename by using VBoxRT.dll before it's initialized.

Location:
trunk/src/VBox
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxBalloonCtrl/VBoxWatchdog.cpp

    r60759 r60865  
    144144static void watchdogShutdown();
    145145
    146 #ifdef RT_OS_WINDOWS
    147 /* Required for ATL. */
    148 static ATL::CComModule _Module;
    149 #endif
    150146
    151147/**
     
    988984    if (RT_FAILURE(rc))
    989985        return RTMsgInitFailure(rc);
     986#ifdef RT_OS_WINDOWS
     987    ATL::CComModule _Module; /* Required internally by ATL (constructor records instance in global variable). */
     988#endif
    990989
    991990    /*
    992991     * Parse the global options
    993     */
     992     */
    994993    int c;
    995994    const char *pszLogFile = NULL;
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp

    r60759 r60865  
    588588}
    589589
    590 #ifdef RT_OS_WINDOWS
    591 // Required for ATL
    592 static ATL::CComModule _Module;
    593 #endif
    594590
    595591#ifdef RT_OS_DARWIN
     
    636632    const char *pszFileNameParam = "VBox-%d.vob";
    637633#endif /* VBOX_WITH_VPX */
     634#ifdef RT_OS_WINDOWS
     635    ATL::CComModule _Module; /* Required internally by ATL (constructor records instance in global variable). */
     636#endif
    638637
    639638    LogFlow(("VBoxHeadless STARTED.\n"));
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r60759 r60865  
    9191static volatile bool    g_fCanceled = false;
    9292
    93 # ifdef RT_OS_WINDOWS
    94 // Required for ATL
    95 static ATL::CComModule  _Module;
    96 # endif
    9793
    9894/**
     
    464460     */
    465461    RTR3InitExe(argc, &argv, 0);
     462#if defined(RT_OS_WINDOWS) && !defined(VBOX_ONLY_DOCS)
     463    ATL::CComModule _Module; /* Required internally by ATL (constructor records instance in global variable). */
     464#endif
    466465
    467466    /*
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r60759 r60865  
    737737
    738738
    739 #ifdef RT_OS_WINDOWS
    740 // Required for ATL
    741 static ATL::CComModule _Module;
    742 #endif
    743 
    744739/** entry point */
    745740extern "C"
    746741DECLEXPORT(int) TrustedMain(int argc, char **argv, char **envp)
    747742{
     743#ifdef RT_OS_WINDOWS
     744    ATL::CComModule _Module; /* Required internally by ATL (constructor records instance in global variable). */
     745#endif
     746
    748747#ifdef Q_WS_X11
    749748    if (!XInitThreads())
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r60862 r60865  
    180180////////////////////////////////////////////////////////////////////////////////
    181181
    182 #ifdef VBOX_WS_WIN
    183 /** ATL requires a module to be instantiated (set internal global variable).
    184  * @note Do NOT do this statically as it starts using IPRT before it's ready! */
    185 static ATL::CComModule *_Module;
    186 #endif
    187182
    188183/* static */
     
    203198    /* Create instance: */
    204199    new VBoxGlobal;
    205 #ifdef VBOX_WS_WIN
    206     _Module = new ATL::CComModule;
    207 #endif
    208200    /* Prepare instance: */
    209201    m_spInstance->prepare();
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r60362 r60865  
    362362extern "C" DECLEXPORT(int) TrustedMain(int argc, char **argv, char ** /*envp*/)
    363363{
     364#ifdef RT_OS_WINDOWS
     365    ATL::CComModule _Module; /* Required internally by ATL (constructor records instance in global variable). */
     366#endif
     367
    364368    /* Failed result initially: */
    365369    int iResultCode = 1;
  • trunk/src/VBox/Main/src-client/win/dllmain.cpp

    r60765 r60865  
    3131*   Global Variables                                                                                                             *
    3232*********************************************************************************************************************************/
    33 static ATL::CComModule _Module;
     33static ATL::CComModule *g_pAtlComModule;
    3434
    3535BEGIN_OBJECT_MAP(ObjectMap)
     
    5050        RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
    5151
    52         _Module.Init(ObjectMap, hInstance, &LIBID_VirtualBox);
     52        g_pAtlComModule = new(ATL::CComModule);
     53        if (!g_pAtlComModule)
     54            return FALSE;
     55
     56        g_pAtlComModule->Init(ObjectMap, hInstance, &LIBID_VirtualBox);
    5357        DisableThreadLibraryCalls(hInstance);
    5458    }
    5559    else if (dwReason == DLL_PROCESS_DETACH)
    5660    {
    57         _Module.Term();
     61        if (g_pAtlComModule)
     62        {
     63            g_pAtlComModule->Term();
     64            delete g_pAtlComModule;
     65            g_pAtlComModule = NULL;
     66        }
    5867    }
    5968    return TRUE;
     
    6574STDAPI DllCanUnloadNow(void)
    6675{
    67     return (_Module.GetLockCount() == 0) ? S_OK : S_FALSE;
     76    AssertReturn(g_pAtlComModule, S_OK);
     77    return g_pAtlComModule->GetLockCount() == 0 ? S_OK : S_FALSE;
    6878}
    6979
     
    7383STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
    7484{
    75     return _Module.GetClassObject(rclsid, riid, ppv);
     85    AssertReturn(g_pAtlComModule, E_UNEXPECTED);
     86    return g_pAtlComModule->GetClassObject(rclsid, riid, ppv);
    7687}
    7788
     
    8394#ifndef VBOX_WITH_MIDL_PROXY_STUB
    8495    // registers object, typelib and all interfaces in typelib
    85     return _Module.RegisterServer(TRUE);
     96    AssertReturn(g_pAtlComModule, E_UNEXPECTED);
     97    return g_pAtlComModule->RegisterServer(TRUE);
    8698#else
    8799    return S_OK; /* VBoxProxyStub does all the work, no need to duplicate it here. */
     
    95107{
    96108#ifndef VBOX_WITH_MIDL_PROXY_STUB
    97     HRESULT hrc = _Module.UnregisterServer(TRUE);
     109    AssertReturn(g_pAtlComModule, E_UNEXPECTED);
     110    HRESULT hrc = g_pAtlComModule->UnregisterServer(TRUE);
    98111    return hrc;
    99112#else
  • trunk/src/VBox/Main/src-server/win/svcmain.cpp

    r60765 r60865  
    131131}
    132132
    133 static CExeModule _Module;
    134133
    135134BEGIN_OBJECT_MAP(ObjectMap)
     
    173172     */
    174173    RTR3InitExe(argc, &argv, 0);
     174    CExeModule _Module;
    175175
    176176    /* Note that all options are given lowercase/camel case/uppercase to
  • trunk/src/VBox/Main/webservice/vboxweb.cpp

    r60536 r60865  
    989989
    990990#ifdef RT_OS_WINDOWS
    991 // Required for ATL
    992 static ATL::CComModule _Module;
    993 
    994991/**
    995992 * "Signal" handler for cleanly terminating the event loop.
     
    10491046    if (RT_FAILURE(rc))
    10501047        return RTMsgInitFailure(rc);
     1048#ifdef RT_OS_WINDOWS
     1049    ATL::CComModule _Module; /* Required internally by ATL (constructor records instance in global variable). */
     1050#endif
    10511051
    10521052    // store a log prefix for this thread
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