Closing SDL window also closes MFC app

Hi,

I’m writing an MFC application which creates a SDL window from a dialog.
But when the SDL window is closed it also closes the dialog and the
application. How can I close only the SDL window?

Thanks,
H?ctor Coderque

Hi,

I’m writing an MFC application which creates a SDL window from a dialog.
But when the SDL window is closed it also closes the dialog and the
application. How can I close only the SDL window?

That sounds like the application is crashing in SDL_Quit(), which usually
means there’s memory corruption in your application. Given that it’s an
MFC application, all bets are off. Try adding the SDL_INIT_NOPARACHUTE
flag to your SDL_Init() call, and see what happens in the debugger.

See ya!
-Sam Lantinga, Software Engineer, Blizzard Entertainment

That sounds like the application is crashing in SDL_Quit(), which usually
means there’s memory corruption in your application. Given that it’s an
MFC application, all bets are off. Try adding the SDL_INIT_NOPARACHUTE
flag to your SDL_Init() call, and see what happens in the debugger.

See ya!
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Hi Sam,

That’s exactly what I’m doing. I call SDL_Init() with SDL_INIT_NOPARACHUTE.
I’ve reduced my application to a very simple one to avoid posible problems
with memory corruption. So, it only creates the dialog and the SDL window.
But it keeps on closing the whole program when I close first the SDL
window. What else can I try to close only the SDL window?

Thanks again,
H?ctor Coderque

Hi Sam,

That’s exactly what I’m doing. I call SDL_Init() with SDL_INIT_NOPARACHUTE.
I’ve reduced my application to a very simple one to avoid posible problems
with memory corruption. So, it only creates the dialog and the SDL window.
But it keeps on closing the whole program when I close first the SDL
window. What else can I try to close only the SDL window?

Like I said, it shouldn’t be closing the entire application. Can you step
into the SDL_Quit() call and see where the application shuts down? You’ll
probably need to build a debug version of the SDL DLL.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Like I said, it shouldn’t be closing the entire application. Can you step
into the SDL_Quit() call and see where the application shuts down? You’ll
probably need to build a debug version of the SDL DLL.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Hi Sam,

I’ve noticed I forgot to link SDLmain.lib. Perhaps it’s what was closing
the entire application…
But now I have other problem when I try to link SDLmain.lib with my MFC
app: ‘unresolved external symbol _SDL_main’.
I know it’s because I must declare int main(int argc, char *argv[]), but my
app is MFC and it starts the program with a class derived from CWinApp
which uses WinMain. How can I solve this?

Thanks,
H?ctor Coderque

Hiya,

dsc> I’ve noticed I forgot to link SDLmain.lib. Perhaps it’s what was closing
dsc> the entire application…

From helping another guy out on this list, it’s been found that you
shouldn’t include SDLmain.lib when using a MFC application. It could
well be something related to that though!

Neil.