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

Improve memory leak in installUI #931

Merged
merged 1 commit into from
Jun 18, 2023
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
9 changes: 5 additions & 4 deletions src/installUI/installUI.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ int main(int argc, char *argv[])

SDL_Surface *waiting_bg = IMG_Load("res/waitingBG.png");
SDL_Surface *progress_stripes = IMG_Load("res/progress_stripes.png");

SDL_Surface *slide = NULL;

TTF_Font *font = TTF_OpenFont("/customer/app/Exo-2-Bold-Italic.ttf", 36);
TTF_Font *font_small =
TTF_OpenFont("/customer/app/Exo-2-Bold-Italic.ttf", 18);
Expand Down Expand Up @@ -127,7 +128,6 @@ int main(int argc, char *argv[])
uint32_t acc_ticks = 0, last_ticks = SDL_GetTicks(),
time_step = 1000 / 24, // 12 fps
check_timer = 0;

uint32_t slide_timer = last_ticks;

while (!quit) {
Expand All @@ -142,10 +142,12 @@ int main(int argc, char *argv[])
switch (event.key.keysym.sym) {
case SW_BTN_LEFT:
current_slide = nextSlide(current_slide, num_slides, -1);
slide = current_slide == -1 ? NULL : imageCache_getItem(&current_slide);
slide_timer = ticks;
break;
case SW_BTN_RIGHT:
current_slide = nextSlide(current_slide, num_slides, 1);
slide = current_slide == -1 ? NULL : imageCache_getItem(&current_slide);
slide_timer = ticks;
break;
case SW_BTN_A:
Expand All @@ -160,6 +162,7 @@ int main(int argc, char *argv[])

if (ticks - slide_timer > SLIDE_TIMEOUT) {
current_slide = nextSlide(current_slide, num_slides, 1);
slide = current_slide == -1 ? NULL : imageCache_getItem(&current_slide);
slide_timer = ticks;
}

Expand Down Expand Up @@ -197,8 +200,6 @@ int main(int argc, char *argv[])
break;

if (acc_ticks >= time_step) {
SDL_Surface *slide =
current_slide == -1 ? NULL : imageCache_getItem(&current_slide);
if (slide == NULL)
SDL_BlitSurface(waiting_bg, NULL, screen, NULL);
else
Expand Down