From 9295e6f5c86b73ee8764aa5a965f70a282e9d290 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Wed, 16 Apr 2025 02:37:48 +0200 Subject: [PATCH 1/3] Qt: Fix gamelist icon after stopping a movie Do not set an icon if it's null. This happens because we save memory by clearing the pixmap of non-movie items. Also don't stop the movie here, as it should be stopped already anyway. --- rpcs3/rpcs3qt/game_list_grid.cpp | 10 +++++----- rpcs3/rpcs3qt/game_list_table.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/rpcs3/rpcs3qt/game_list_grid.cpp b/rpcs3/rpcs3qt/game_list_grid.cpp index 5d4b90203f..4a762f288c 100644 --- a/rpcs3/rpcs3qt/game_list_grid.cpp +++ b/rpcs3/rpcs3qt/game_list_grid.cpp @@ -91,19 +91,19 @@ void game_list_grid::populate( if (const QPixmap pixmap = item->get_movie_image(frame); item->get_active() && !pixmap.isNull()) { item->set_icon(gui::utils::get_centered_pixmap(pixmap, m_icon_size, 0, 0, 1.0, Qt::FastTransformation)); + return; } - else - { - std::lock_guard lock(item->pixmap_mutex); + std::lock_guard lock(item->pixmap_mutex); + + if (!game->pxmap.isNull()) + { item->set_icon(game->pxmap); if (!game->has_hover_gif && !game->has_hover_pam) { game->pxmap = {}; } - - item->stop_movie(); } }); diff --git a/rpcs3/rpcs3qt/game_list_table.cpp b/rpcs3/rpcs3qt/game_list_table.cpp index 96f94787b5..31950ab177 100644 --- a/rpcs3/rpcs3qt/game_list_table.cpp +++ b/rpcs3/rpcs3qt/game_list_table.cpp @@ -252,19 +252,19 @@ void game_list_table::populate( if (const QPixmap pixmap = icon_item->get_movie_image(frame); icon_item->get_active() && !pixmap.isNull()) { icon_item->setData(Qt::DecorationRole, pixmap.scaled(m_icon_size, Qt::KeepAspectRatio)); + return; } - else - { - std::lock_guard lock(icon_item->pixmap_mutex); + std::lock_guard lock(icon_item->pixmap_mutex); + + if (!game->pxmap.isNull()) + { icon_item->setData(Qt::DecorationRole, game->pxmap); if (!game->has_hover_gif && !game->has_hover_pam) { game->pxmap = {}; } - - icon_item->stop_movie(); } }); From b96e41285c644afb8c6b73442070ac47ca279011 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Wed, 16 Apr 2025 02:41:33 +0200 Subject: [PATCH 2/3] Qt: use unique_ptr in qt_video_source --- rpcs3/rpcs3qt/qt_video_source.cpp | 8 ++++---- rpcs3/rpcs3qt/qt_video_source.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rpcs3/rpcs3qt/qt_video_source.cpp b/rpcs3/rpcs3qt/qt_video_source.cpp index ad5332d1bf..c56fb35bc7 100644 --- a/rpcs3/rpcs3qt/qt_video_source.cpp +++ b/rpcs3/rpcs3qt/qt_video_source.cpp @@ -65,7 +65,7 @@ void qt_video_source::init_movie() if (lower.endsWith(".gif")) { - m_movie.reset(new QMovie(m_video_path)); + m_movie = std::make_unique(m_video_path); m_video_path.clear(); if (!m_movie->isValid()) @@ -98,18 +98,18 @@ void qt_video_source::init_movie() return; } - m_video_buffer.reset(new QBuffer(&m_video_data)); + m_video_buffer = std::make_unique(&m_video_data); m_video_buffer->open(QIODevice::ReadOnly); } - m_video_sink.reset(new QVideoSink()); + m_video_sink = std::make_unique(); QObject::connect(m_video_sink.get(), &QVideoSink::videoFrameChanged, m_video_sink.get(), [this](const QVideoFrame& frame) { m_image_change_callback(frame); m_has_new = true; }); - m_media_player.reset(new QMediaPlayer()); + m_media_player = std::make_unique(); m_media_player->setVideoSink(m_video_sink.get()); m_media_player->setLoops(QMediaPlayer::Infinite); diff --git a/rpcs3/rpcs3qt/qt_video_source.h b/rpcs3/rpcs3qt/qt_video_source.h index 27f716f0d4..37fe5fa280 100644 --- a/rpcs3/rpcs3qt/qt_video_source.h +++ b/rpcs3/rpcs3qt/qt_video_source.h @@ -49,8 +49,8 @@ protected: std::unique_ptr m_video_buffer; std::unique_ptr m_media_player; - std::shared_ptr m_video_sink; - std::shared_ptr m_movie; + std::unique_ptr m_video_sink; + std::unique_ptr m_movie; std::function m_image_change_callback = nullptr; From b51d6e9d92d1204aecfe1c9af83948102b98a0df Mon Sep 17 00:00:00 2001 From: Megamouse Date: Wed, 16 Apr 2025 02:48:12 +0200 Subject: [PATCH 3/3] Qt: use image_change_callback function to ensure the member is valid --- rpcs3/rpcs3qt/qt_video_source.cpp | 8 ++++---- rpcs3/rpcs3qt/qt_video_source.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rpcs3/rpcs3qt/qt_video_source.cpp b/rpcs3/rpcs3qt/qt_video_source.cpp index c56fb35bc7..107e5ef850 100644 --- a/rpcs3/rpcs3qt/qt_video_source.cpp +++ b/rpcs3/rpcs3qt/qt_video_source.cpp @@ -34,11 +34,11 @@ void qt_video_source::set_active(bool active) } } -void qt_video_source::image_change_callback() const +void qt_video_source::image_change_callback(const QVideoFrame& frame) const { if (m_image_change_callback) { - m_image_change_callback({}); + m_image_change_callback(frame); } } @@ -76,7 +76,7 @@ void qt_video_source::init_movie() QObject::connect(m_movie.get(), &QMovie::frameChanged, m_movie.get(), [this](int) { - m_image_change_callback({}); + image_change_callback(); m_has_new = true; }); return; @@ -105,7 +105,7 @@ void qt_video_source::init_movie() m_video_sink = std::make_unique(); QObject::connect(m_video_sink.get(), &QVideoSink::videoFrameChanged, m_video_sink.get(), [this](const QVideoFrame& frame) { - m_image_change_callback(frame); + image_change_callback(frame); m_has_new = true; }); diff --git a/rpcs3/rpcs3qt/qt_video_source.h b/rpcs3/rpcs3qt/qt_video_source.h index 37fe5fa280..a2710eea33 100644 --- a/rpcs3/rpcs3qt/qt_video_source.h +++ b/rpcs3/rpcs3qt/qt_video_source.h @@ -31,7 +31,7 @@ public: QPixmap get_movie_image(const QVideoFrame& frame) const; - void image_change_callback() const; + void image_change_callback(const QVideoFrame& frame = {}) const; void set_image_change_callback(const std::function& func); protected: