You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If two different instances of a subsystem object are acquired from the main Sdl object, the subsystem will be shut down when any one of these instances is dropped. For example:
externcrate sdl2;fnmain(){let sdl = sdl2::init().unwrap();let _video1 = sdl.video().unwrap();{let _video2 = sdl.video().unwrap();}// SDL_QuitSubSystem is called here// ...}
SDL_QuitSubSystem is called when _video2 is dropped even though _video1 is still alive. This is because each instance holds a reference to a different SubsystemDrop.
A possible solution is to store a Weak<SubsystemDrop> for each subsystem in the main SdlDrop. Then when the subsystem is requested, the SubsystemDrop can be acquired from here if it already exists.
The text was updated successfully, but these errors were encountered:
daggerbot
changed the title
Subsystems may be dropped while they're still being used
Subsystems may be shut down while they're still being used
Aug 20, 2022
We could use atomic integers to prevent a subsystem being destroyed when it shouldn't. And while we're at it, we could prevent a subsystem from being initialized if it has already been initialized.
If two different instances of a subsystem object are acquired from the main
Sdl
object, the subsystem will be shut down when any one of these instances is dropped. For example:SDL_QuitSubSystem
is called when_video2
is dropped even though_video1
is still alive. This is because each instance holds a reference to a differentSubsystemDrop
.A possible solution is to store a
Weak<SubsystemDrop>
for each subsystem in the mainSdlDrop
. Then when the subsystem is requested, theSubsystemDrop
can be acquired from here if it already exists.The text was updated successfully, but these errors were encountered: