Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdl: fix exiting while waiting for a render to be presented #876

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions 32blit-sdl/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,16 +445,19 @@ void System::set_button(int button, bool state) {
}

void System::stop() {
int returnValue;
running = false;
int returnValue;
running = false;

if(SDL_SemWaitTimeout(s_loop_ended, 500)) {
std::cerr << "User code appears to have frozen. Detaching thread." << std::endl;
SDL_DetachThread(t_system_loop);
} else {
SDL_WaitThread(t_system_loop, &returnValue);
}
// make sure the update thread is not waiting for a render to complete
SDL_SemPost(s_loop_redraw);

if(SDL_SemWaitTimeout(s_loop_ended, 500)) {
std::cerr << "User code appears to have frozen. Detaching thread." << std::endl;
SDL_DetachThread(t_system_loop);
} else {
SDL_WaitThread(t_system_loop, &returnValue);
}

SDL_SemPost(s_timer_stop);
SDL_WaitThread(t_system_timer, &returnValue);
SDL_SemPost(s_timer_stop);
SDL_WaitThread(t_system_timer, &returnValue);
}
Loading