Fixed ignoring first event in testshape program.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Thu, 08 Jun 2017 22:40:35 +0200
changeset 110801677ac34c68c
parent 11079 08bbd51693d6
child 11081 eea7f98a37e4
Fixed ignoring first event in testshape program.

Found by Cppcheck.
test/testshape.c
     1.1 --- a/test/testshape.c	Thu Jun 08 22:40:21 2017 +0200
     1.2 +++ b/test/testshape.c	Thu Jun 08 22:40:35 2017 +0200
     1.3 @@ -48,7 +48,6 @@
     1.4      SDL_Renderer *renderer;
     1.5      SDL_Color black = {0,0,0,0xff};
     1.6      SDL_Event event;
     1.7 -    int event_pending = 0;
     1.8      int should_exit = 0;
     1.9      unsigned int current_picture;
    1.10      int button_down;
    1.11 @@ -143,9 +142,7 @@
    1.12          }
    1.13      }
    1.14  
    1.15 -    event_pending = 0;
    1.16      should_exit = 0;
    1.17 -    event_pending = SDL_PollEvent(&event);
    1.18      current_picture = 0;
    1.19      button_down = 0;
    1.20      texture_dimensions.h = 0;
    1.21 @@ -157,8 +154,7 @@
    1.22      SDL_SetWindowSize(window,texture_dimensions.w,texture_dimensions.h);
    1.23      SDL_SetWindowShape(window,pictures[current_picture].surface,&pictures[current_picture].mode);
    1.24      while(should_exit == 0) {
    1.25 -        event_pending = SDL_PollEvent(&event);
    1.26 -        if(event_pending == 1) {
    1.27 +        if (SDL_PollEvent(&event)) {
    1.28              if(event.type == SDL_KEYDOWN) {
    1.29                  button_down = 1;
    1.30                  if(event.key.keysym.sym == SDLK_ESCAPE) {
    1.31 @@ -178,7 +174,6 @@
    1.32              }
    1.33              if(event.type == SDL_QUIT)
    1.34                  should_exit = 1;
    1.35 -            event_pending = 0;
    1.36          }
    1.37          render(renderer,pictures[current_picture].texture,texture_dimensions);
    1.38          SDL_Delay(10);