I'm making an app using SDL 2. I just recently started using the SDL_Mixer library and this has brought about an issue for me. Forgive me if my explanation seems vague, as this bug is extremely confusing.
Sometimes, when closing out of my program, the program crashes. Only sometimes this happens. After removing parts of code, I found that the line causing this was a simple delete
call on a pointer of type Window*
. If I remove that delete call, no more crashes happen when I close the program. Another thing that's important to note is that the crash occurs right after delete
is called, meaning the program doesn't even go inside of ~Window()
which is really strange.
Something else I noticed was that when I remove the Mix_OpenAudio(...)
call from the beginning of the program, no crashes happen at all, regardless of whether or not the delete call is there. So initializing SDL_Mixer has something to do with the crashes, but this just adds more confusion.
I'm hoping that someone has an idea of what could be the problem here, but if my explanation is too vague then I'll try to replicate the problem into a small enough segment of code that I can post here. I didn't want to copy my entire codebase onto this question because I don't want the mods to hate me. Any ideas?