Browse Source

Don't do work in DllMain.

If you don't know why I did this, please Google why you should never do
work in DllMain.
Adam Johnson 11 years ago
parent
commit
85d64926d2
  1. 15
      Sources/Tools/MaxMain/GlobalUtility.cpp
  2. 41
      Sources/Tools/MaxMain/main.cpp

15
Sources/Tools/MaxMain/GlobalUtility.cpp

@ -62,6 +62,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pfLocalizationMgr/pfLocalizationMgr.h" #include "pfLocalizationMgr/pfLocalizationMgr.h"
#include "plGImage/plFontCache.h" #include "plGImage/plFontCache.h"
#include "plPythonMgr.h"
#include "plPluginResManager.h"
#include "plSDL/plSDL.h"
extern plActionTableMgr theActionTableMgr; extern plActionTableMgr theActionTableMgr;
extern HINSTANCE hInstance; extern HINSTANCE hInstance;
@ -169,7 +173,6 @@ DWORD PlasmaMax::Start()
DummyCodeIncludeFuncClickDrag(); //Click-Draggable comp DummyCodeIncludeFuncClickDrag(); //Click-Draggable comp
DummyCodeIncludeFuncInventStuff(); //Inventory Object comp DummyCodeIncludeFuncInventStuff(); //Inventory Object comp
DummyCodeIncludeFuncVolumeGadget(); // inside/enter/exit phys volume activator DummyCodeIncludeFuncVolumeGadget(); // inside/enter/exit phys volume activator
// DummyCodeIncludeFuncActivatorGadget(); // activator activator
DummyCodeIncludeFuncSoftVolume(); // Soft Volumes DummyCodeIncludeFuncSoftVolume(); // Soft Volumes
DummyCodeIncludeFuncPhysConst(); // Phys Constraints DummyCodeIncludeFuncPhysConst(); // Phys Constraints
DummyCodeIncludeFuncCameras(); // new camera code DummyCodeIncludeFuncCameras(); // new camera code
@ -211,6 +214,16 @@ DWORD PlasmaMax::Start()
return GUPRESULT_NOKEEP; return GUPRESULT_NOKEEP;
} }
// Load S-D-teh-Ls
plFileName oldCwd = plFileSystem::GetCWD();
plFileSystem::SetCWD(pathTemp);
plSDLMgr::GetInstance()->Init();
plFileSystem::SetCWD(oldCwd);
// Initialize the ResManager and Python
plPythonMgr::Instance().LoadPythonFiles();
hsgResMgr::Init(new plPluginResManager);
// Setup the doggone plugin // Setup the doggone plugin
plComponentShow::Init(); plComponentShow::Init();
plCreateMenu(); plCreateMenu();

41
Sources/Tools/MaxMain/main.cpp

@ -57,14 +57,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#pragma hdrstop #pragma hdrstop
#include "MaxExport/SimpleExport.h" #include "MaxExport/SimpleExport.h"
#include "MaxPlasmaMtls/plMtlImport.h" #include "MaxPlasmaMtls/plMtlImport.h"
#include "plPythonMgr.h"
#include "plPluginResManager.h"
#include "plSDL/plSDL.h"
#include "plMaxCFGFile.h"
extern ClassDesc* GetGUPDesc(); extern ClassDesc* GetGUPDesc();
extern ClassDesc* GetComponentUtilDesc(); extern ClassDesc* GetComponentUtilDesc();
extern ClassDesc* GetComponentMgrDesc(); extern ClassDesc* GetComponentMgrDesc();
@ -72,7 +66,6 @@ extern ClassDesc* GetMaxFileDataDesc();
extern ClassDesc* GetMaxUtilsDesc(); extern ClassDesc* GetMaxUtilsDesc();
static HSClassDesc2 HSDesc; static HSClassDesc2 HSDesc;
static int controlsInit = FALSE;
HINSTANCE hInstance = NULL; HINSTANCE hInstance = NULL;
/*inline*/ TCHAR *GetString(int id) /*inline*/ TCHAR *GetString(int id)
@ -113,7 +106,7 @@ __declspec(dllexport) ClassDesc *LibClassDesc(int i)
switch(i) switch(i)
{ {
case 0: case 0:
return &HSDesc; return &HSDesc;
case 1: case 1:
return GetGUPDesc(); return GetGUPDesc();
case 2: case 2:
@ -151,35 +144,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved)
{ {
hInstance = hinstDLL; hInstance = hinstDLL;
if (!controlsInit) switch (fdwReason)
{
controlsInit = TRUE;
// jaguar controls
INIT_CUSTOM_CONTROLS(hInstance);
// initialize Chicago controls
InitCommonControls();
plPythonMgr::Instance().LoadPythonFiles();
plFileName clientPath = plMaxConfig::GetClientPath(false, true);
if (clientPath.IsValid())
{
plFileName oldCwd = plFileSystem::GetCWD();
plFileSystem::SetCWD(clientPath);
plSDLMgr::GetInstance()->Init();
plFileSystem::SetCWD(oldCwd);
}
// Initialize the ResManager
plResManager* pRmgr = new plPluginResManager;
hsgResMgr::Init(pRmgr);
}
switch (fdwReason)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
INIT_CUSTOM_CONTROLS(hInstance);
break; break;
case DLL_THREAD_ATTACH: case DLL_THREAD_ATTACH:
break; break;
@ -188,7 +156,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved)
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
break; break;
} }
return(TRUE);
return TRUE;
} }
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////

Loading…
Cancel
Save