Patch by Magliocchetti Riccardo:
fix may be used uninitialized, while at it add proper error checking in fps limiter code
This commit is contained in:
parent
e46a6e093f
commit
d6e9f00ebc
|
@ -559,8 +559,8 @@ int main(int argc, char ** argv) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int limiter_frame_counter = 0;
|
int limiter_frame_counter = 0;
|
||||||
SDL_sem *fps_limiter_semaphore;
|
SDL_sem *fps_limiter_semaphore = NULL;
|
||||||
SDL_TimerID limiter_timer;
|
SDL_TimerID limiter_timer = NULL;
|
||||||
int sdl_quit = 0;
|
int sdl_quit = 0;
|
||||||
|
|
||||||
#ifdef DISPLAY_FPS
|
#ifdef DISPLAY_FPS
|
||||||
|
@ -745,11 +745,18 @@ int main(int argc, char ** argv) {
|
||||||
fps_limiter_semaphore = SDL_CreateSemaphore( 1);
|
fps_limiter_semaphore = SDL_CreateSemaphore( 1);
|
||||||
|
|
||||||
/* start a SDL timer for every FPS_LIMITER_FRAME_PERIOD frames to keep us at 60 fps */
|
/* start a SDL timer for every FPS_LIMITER_FRAME_PERIOD frames to keep us at 60 fps */
|
||||||
|
if ( fps_limiter_semaphore != NULL) {
|
||||||
limiter_timer = SDL_AddTimer( 16 * FPS_LIMITER_FRAME_PERIOD,
|
limiter_timer = SDL_AddTimer( 16 * FPS_LIMITER_FRAME_PERIOD,
|
||||||
fps_limiter_fn, fps_limiter_semaphore);
|
fps_limiter_fn, fps_limiter_semaphore);
|
||||||
|
}
|
||||||
|
|
||||||
if ( limiter_timer == NULL) {
|
if ( limiter_timer == NULL) {
|
||||||
fprintf( stderr, "Error trying to start FPS limiter timer: %s\n",
|
fprintf( stderr, "Error trying to start FPS limiter timer: %s\n",
|
||||||
SDL_GetError());
|
SDL_GetError());
|
||||||
|
if ( fps_limiter_semaphore != NULL) {
|
||||||
|
SDL_DestroySemaphore( fps_limiter_semaphore);
|
||||||
|
fps_limiter_semaphore = NULL;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue