In SDL2 the exit event NOT turn off the window

According to source code(https://lazyfoo.net/tutorials/SDL/03_event_driven_programming/03_event_driven_programming.zip),After compilation,when the Program running,the image can be shown,but when i Click exit X in the upper right corner of the window,nothing happed.in the source code,i can see 1 ,it means that
the exit event was handled,but why the window still here,It’s not turned off?at the same time ,the Minimum buttons _ are valid.

Can’t see what you’re doing after the mainloop (while( !quit ){}) ends. Do you destroy the window by calling SDL_DestroyWindow(gWindow)?

after the mainloop,only handle the xs event,but the xs event don’t change the quit to true;then close() don’t run,the window is still open state.

Set a breakpoint in the event loop and check that the SDL_QUIT event actually happen when the window X is pressed.

You wrote in your first post that the exit event happens but make sure that it actually does.

yes,I have set breakpoint after poolevent(),find no event(SDL_QUIT) be pooled,so I try to get some data about poolevent.

thanks Daniel1985,i have found the solution,the close () function ,it’s the problem;i changed close() to xclose(),then it’s ok now.

Glad to hear the issue got solved. :slight_smile: