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 "plGImage/plFontCache.h"
#include "plPythonMgr.h"
#include "plPluginResManager.h"
#include "plSDL/plSDL.h"
extern plActionTableMgr theActionTableMgr;
extern HINSTANCE hInstance;
@ -169,7 +173,6 @@ DWORD PlasmaMax::Start()
DummyCodeIncludeFuncClickDrag(); //Click-Draggable comp
DummyCodeIncludeFuncInventStuff(); //Inventory Object comp
DummyCodeIncludeFuncVolumeGadget(); // inside/enter/exit phys volume activator
// DummyCodeIncludeFuncActivatorGadget(); // activator activator
DummyCodeIncludeFuncSoftVolume(); // Soft Volumes
DummyCodeIncludeFuncPhysConst(); // Phys Constraints
DummyCodeIncludeFuncCameras(); // new camera code
@ -211,6 +214,16 @@ DWORD PlasmaMax::Start()
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
plComponentShow::Init();
plCreateMenu();

41
Sources/Tools/MaxMain/main.cpp

@ -57,14 +57,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#pragma hdrstop
#include "MaxExport/SimpleExport.h"
#include "MaxPlasmaMtls/plMtlImport.h"
#include "plPythonMgr.h"
#include "plPluginResManager.h"
#include "plSDL/plSDL.h"
#include "plMaxCFGFile.h"
extern ClassDesc* GetGUPDesc();
extern ClassDesc* GetComponentUtilDesc();
extern ClassDesc* GetComponentMgrDesc();
@ -72,7 +66,6 @@ extern ClassDesc* GetMaxFileDataDesc();
extern ClassDesc* GetMaxUtilsDesc();
static HSClassDesc2 HSDesc;
static int controlsInit = FALSE;
HINSTANCE hInstance = NULL;
/*inline*/ TCHAR *GetString(int id)
@ -113,7 +106,7 @@ __declspec(dllexport) ClassDesc *LibClassDesc(int i)
switch(i)
{
case 0:
return &HSDesc;
return &HSDesc;
case 1:
return GetGUPDesc();
case 2:
@ -151,35 +144,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved)
{
hInstance = hinstDLL;
if (!controlsInit)
{
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)
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
INIT_CUSTOM_CONTROLS(hInstance);
break;
case DLL_THREAD_ATTACH:
break;
@ -188,7 +156,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved)
case DLL_PROCESS_DETACH:
break;
}
return(TRUE);
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////////

Loading…
Cancel
Save