Skip to content

Commit

Permalink
Cleanup screenshot memory management [Tantric]
Browse files Browse the repository at this point in the history
This should fix the preview image not displaying on Gamecube.
  • Loading branch information
niuus authored Jul 25, 2019
1 parent 0add3d0 commit eaf292c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
9 changes: 2 additions & 7 deletions source/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1575,8 +1575,7 @@ static int MenuGame()
delete gameScreenImg;
delete gameScreen;
gameScreen = NULL;
free(gameScreenPng);
gameScreenPng = NULL;
ClearScreenshot();
gameScreenImg = new GuiImage(screenwidth, screenheight, (GXColor){175, 200, 215, 255});
gameScreenImg->ColorStripe(10);
mainWindow->Insert(gameScreenImg, 0);
Expand Down Expand Up @@ -4366,11 +4365,7 @@ MainMenu (int menu)
if(gameScreen)
delete gameScreen;

if(gameScreenPng)
{
free(gameScreenPng);
gameScreenPng = NULL;
}
ClearScreenshot();

// wait for keys to be depressed
while(MenuRequested())
Expand Down
10 changes: 10 additions & 0 deletions source/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,16 @@ void TakeScreenshot()
}
}

void ClearScreenshot()
{
if(gameScreenPng)
{
gameScreenPngSize = 0;
free(gameScreenPng);
gameScreenPng = NULL;
}
}

/****************************************************************************
* ResetVideo_Menu
*
Expand Down
1 change: 1 addition & 0 deletions source/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void setGFX();
void update_video (int width, int height);
void ResetVideo_Menu();
void TakeScreenshot();
void ClearScreenshot();
void Menu_Render();
void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[], f32 degrees, f32 scaleX, f32 scaleY, u8 alphaF );
void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled);
Expand Down

0 comments on commit eaf292c

Please sign in to comment.