Skip to content

Commit

Permalink
Fix #1323: Reset IS_MAIN_THREAD_DECLARED on drop
Browse files Browse the repository at this point in the history
  • Loading branch information
austindoupnik committed Sep 14, 2023
1 parent 5a0f7da commit 3395e4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ when upgrading from a version of rust-sdl2 to another.

[PR #1332](https://github.com/Rust-SDL2/rust-sdl2/pull/1332) Fix `size_hint` implementations for `{audio,video,render}::DriverIterator`

[PR #1337](https://github.com/Rust-SDL2/rust-sdl2/pull/1337) Fix "Cannot initialize Sdl from more than one thread" for tests / CI

### v0.35.2

[PR #1173](https://github.com/Rust-SDL2/rust-sdl2/pull/1173) Fix segfault when using timer callbacks
Expand Down
3 changes: 2 additions & 1 deletion src/sdl2/sdl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Sdl {
IS_MAIN_THREAD.with(|is_main_thread| {
if was_main_thread_declared {
if !is_main_thread.get() {
return Err("Cannot initialize `Sdl` from more than once thread.".to_owned());
return Err("Cannot initialize `Sdl` from more than one thread.".to_owned());
}
} else {
is_main_thread.set(true);
Expand Down Expand Up @@ -209,6 +209,7 @@ impl Drop for SdlDrop {
unsafe {
sys::SDL_Quit();
}
IS_MAIN_THREAD_DECLARED.swap(false, Ordering::SeqCst);
}
}
}
Expand Down

0 comments on commit 3395e4e

Please sign in to comment.