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;
QPixmap icon;
QPixmap pxmap;
bool hasCustomConfig;
bool hasCustomPadConfig;
bool has_hover_gif;
movie_item* item;
bool hasCustomConfig = false;
bool hasCustomPadConfig = false;
bool has_hover_gif = false;
movie_item* item = nullptr;
};
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)
{
ensure(icon_item);
ensure(icon_item && game);
if (QMovie* movie = icon_item->movie(); movie && icon_item->get_active())
{
@ -2298,6 +2298,12 @@ void game_list_frame::PopulateGameList()
else
{
icon_item->setData(Qt::DecorationRole, game->pxmap);
if (!game->has_hover_gif)
{
game->pxmap = {};
}
if (movie)
{
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.drawPixmap(offset, app->pxmap);
if (!app->has_hover_gif)
{
app->pxmap = {};
}
if (movie)
{
movie->stop();