Not much of an issue, but I’m not sure if this is supposed to be safe or not:
Calling SDL_JoystickClose() after closing SDL may cause a segfault.
(SDL 1.2.14, Linux/x86_64)
Normal application code would never do that, but it can easily happen when
wrapping the API in a language with automatic memory management. I deal with
it like this in my joystick wrapper destructor:
…which is perfectly fine by me in this case - although personally, I prefer
it when APIs don’t pull things out from under the application, or at least do
it safely. :-)–
//David Olofson - Consultant, Developer, Artist, Open Source Advocate
Not much of an issue, but I’m not sure if this is supposed to be safe or
not:
Calling SDL_JoystickClose() after closing SDL may cause a segfault.
(SDL 1.2.14, Linux/x86_64)
Normal application code would never do that, but it can easily happen when
wrapping the API in a language with automatic memory management. I deal
with
it like this in my joystick wrapper destructor:
…which is perfectly fine by me in this case - although personally, I
prefer
it when APIs don’t pull things out from under the application, or at least
do
it safely.
–
//David Olofson - Consultant, Developer, Artist, Open Source Advocate
Hi, we (the SDL Perl ppl) doing something like:
Perl_call_atexit( SDL_quit )
This is called automagically when perl shuts down. The programs mustnt call SDL_quit unless they want to reinitialize it afterwards again.
Cheers, FROGGS
Ren? Dudfield hat geschrieben:>On Wed, Aug 31, 2011 at 2:30 PM, David Olofson wrote:
Not much of an issue, but I’m not sure if this is supposed to be safe or
not:
Calling SDL_JoystickClose() after closing SDL may cause a segfault.
(SDL 1.2.14, Linux/x86_64)
Normal application code would never do that, but it can easily happen when
wrapping the API in a language with automatic memory management. I deal
with
it like this in my joystick wrapper destructor:
…which is perfectly fine by me in this case - although personally, I
prefer
it when APIs don’t pull things out from under the application, or at least
do
it safely.
–
//David Olofson - Consultant, Developer, Artist, Open Source Advocate
A little note that might be useful for other dyn languages…
pygame for python works by registering a quit function for each SDL module.
So when it quits, it does various cleanups before closing SDL. The joystick
module loops through the joysticks and closes them, then quits the joystick
subsystem. The same function is reused if we just quit the joystick
subsystem.On Thu, Sep 1, 2011 at 10:35 AM, Ryan C. Gordon wrote: