| Summary: | SDL_Init is crashing when called from DLL_main | ||
|---|---|---|---|
| Product: | SDL | Reporter: | fojtik |
| Component: | joystick | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED WONTFIX | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 1.2.14 | ||
| Hardware: | x86 | ||
| OS: | Windows (XP) | ||
I suspect there's some problems on Windows with loading DLLs while a DLL is being loaded. I have finally used native Windows joystick calls and do not use this library. There is no other place to initialise joystick, only dll_main is available. The resulting DLL is intended to be a plugin for Matlab. |
The code hangs. If I call SDL_Init(SDL_INIT_JOYSTICK) outdide DllMain, It does not crash. ---------------------------------------------------------- SDL_Joystick *joystick; int JoystickNumAxes; /** Main Windows .dll initialisation entry point. */ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { switch(fdwReason) { case DLL_PROCESS_ATTACH: { if(SDL_Init(SDL_INIT_JOYSTICK)==0) { joystick = SDL_JoystickOpen(0); JoystickNumAxes = SDL_JoystickNumAxes(joystick); } else joystick = NULL; break; } case DLL_PROCESS_DETACH: if (joystick) { SDL_JoystickClose(joystick); joystick = NULL; } //numAxes = numButtons = numHats = numTrackballs = 0; break; //case DLL_THREAD_ATTACH: //case DLL_THREAD_DETACH: } return TRUE; }