Qt: release scaled pixmaps from memory if possible

This commit is contained in:
Megamouse 2021-09-08 01:00:49 +02:00
parent 4d70c483b2
commit 2fb68bfc03
3 changed files with 16 additions and 5 deletions

View file

@ -17,10 +17,10 @@ struct gui_game_info
compat::status compat; compat::status compat;
QPixmap icon; QPixmap icon;
QPixmap pxmap; QPixmap pxmap;
bool hasCustomConfig; bool hasCustomConfig = false;
bool hasCustomPadConfig; bool hasCustomPadConfig = false;
bool has_hover_gif; bool has_hover_gif = false;
movie_item* item; movie_item* item = nullptr;
}; };
typedef std::shared_ptr<gui_game_info> game_info; typedef std::shared_ptr<gui_game_info> game_info;

View file

@ -2289,7 +2289,7 @@ void game_list_frame::PopulateGameList()
icon_item->set_icon_func([this, icon_item, game](int) icon_item->set_icon_func([this, icon_item, game](int)
{ {
ensure(icon_item); ensure(icon_item && game);
if (QMovie* movie = icon_item->movie(); movie && icon_item->get_active()) if (QMovie* movie = icon_item->movie(); movie && icon_item->get_active())
{ {
@ -2298,6 +2298,12 @@ void game_list_frame::PopulateGameList()
else else
{ {
icon_item->setData(Qt::DecorationRole, game->pxmap); icon_item->setData(Qt::DecorationRole, game->pxmap);
if (!game->has_hover_gif)
{
game->pxmap = {};
}
if (movie) if (movie)
{ {
movie->stop(); movie->stop();

View file

@ -114,6 +114,11 @@ movie_item* game_list_grid::addItem(const game_info& app, const QString& name, c
painter.drawImage(offset, bg_img); painter.drawImage(offset, bg_img);
painter.drawPixmap(offset, app->pxmap); painter.drawPixmap(offset, app->pxmap);
if (!app->has_hover_gif)
{
app->pxmap = {};
}
if (movie) if (movie)
{ {
movie->stop(); movie->stop();