Check for errors when exiting the main loop
If we didn't exit by setting running to false then we must have
exited due to SDL_WaitEvents returning an error. Print that error.
Then set running to false to ensure the thread quits.
@@ -420,6 +420,10 @@ int main(int argc, char *argv[]) {
break;
}
}
+ if (running) {
+ fprintf(stderr, "Main loop exited with error: %s\n", SDL_GetError());
+ running = false; // ensure timer thread quits
+ }
int returnValue;
SDL_WaitThread(t_system_timer, &returnValue);
