-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Object destruction issues... #313
Comments
Did you see my comment about exposing the SDL_ObjectValid() API? |
Actually, I don't see my comment either, but the idea was that maybe we should expose the SDL_ObjectValid() API and allow the application (and sdl2-compat) register new object types and we can use that to validate pointers before dereferencing them. This might also help the window surface issue that you ran into earlier. |
Hmm, this could work. |
Okay for the sake of argument here, we just want a thing that a) registers a The SDL_ObjectType part makes this dicey for a public API, because now we need to let people track their own types, taking into account that the SDL_ObjectType enum will increase in future SDL3 releases. Unless we either let them have a single SDL_OBJECT_TYPE_GENERIC_POINTER and they're on their own. Also, do we want apps to be able to query if a window pointer is valid, etc? It seems harmless, but also like there might be ramifications I haven't thought of. I think for now I might just drop a dirt-simple hash table into sdl2-compat and leave it at that. We can always expose this API in SDL3 later and take advantage of it in sdl2-compat then. |
Maybe a public API can just expose those three functions and use SDL_OBJECT_TYPE_GENERIC_POINTER internally?
That seems fine too. Might as well drop in the SDL3 hashtable implementation though, we know it's fast and good. |
Should we just make the hashtable a public SDL3 API at this point...? |
It would fix libsdl-org/SDL_ttf#508 ... |
Okay, I'm going to do that after lunch. |
Should it go in 3.4? I already broke the "no new functions in minor release" rule, but ...? |
What's the value of only adding them on minor version boundaries? |
You have forward and backward compatibility in minor versions. |
I'm cleaning this up for a PR, we can merge whenever it makes sense. |
FYI, I just ran into this with py-sdl2 and the gui.py example. It loads a BMP file, then calls SDL_Quit(), then the python garbage collection runs and cleans up the SDL2 surface, which is no longer valid. |
Yeah, lots of things are hitting this. I'm almost done cleaning up the hash table stuff, and then this will be trivial to fix. |
The application might free surfaces and audio streams after SDL_Quit(), which is allowed. Wesnoth and 'python py-sdl2/examples/gui.py' both exit cleanly now. Fixes libsdl-org#313
The application might free surfaces and audio streams after SDL_Quit(), which is allowed. Wesnoth and 'python py-sdl2/examples/gui.py' both exit cleanly now. Fixes #313
Something I'm seeing in a lot of the apps we've fixed things in over the last several days:
SDL3 already destroyed these things during SDL_Quit, which I don't think SDL2 does, so when the static destructors run, they're already gone.
Here's The Battle For Wesnoth, just starting and clicking the window bar's close button on the main menu:
...and here it is again, it blew up on an AudioStream this time...
Some things obviously shouldn't work after SDL_Quit()...like an SDL_Texture, if that wasn't something we clean up, or whatever, but one could argue a Surface or AudioStream might still be useful, so we might need a hint to tell SDL3 not to clean stuff up.
Alternately, we can add a hack to sdl2-compat's SDL_FreeSurface() to make it return immediately after SDL_Quit() has been called.
The text was updated successfully, but these errors were encountered: