mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-14 01:27:00 +00:00
Qt: fix size watcher cancellation on soft refresh
Also setting the cancel flag manually since the canceled signal seems to be very unreliable (I managed to trigger it rarely)
This commit is contained in:
parent
382a27cb2f
commit
98dbbd84ac
@ -139,7 +139,7 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> gui_settings, std
|
||||
connect(&m_refresh_watcher, &QFutureWatcher<void>::finished, this, &game_list_frame::OnRefreshFinished);
|
||||
connect(&m_refresh_watcher, &QFutureWatcher<void>::canceled, this, [this]()
|
||||
{
|
||||
gui::utils::stop_future_watcher(m_size_watcher, true);
|
||||
gui::utils::stop_future_watcher(m_size_watcher, true, m_size_watcher_cancel);
|
||||
gui::utils::stop_future_watcher(m_repaint_watcher, true);
|
||||
|
||||
m_path_list.clear();
|
||||
@ -436,7 +436,10 @@ std::string game_list_frame::GetDataDirBySerial(const std::string& serial)
|
||||
|
||||
void game_list_frame::Refresh(const bool from_drive, const bool scroll_after)
|
||||
{
|
||||
gui::utils::stop_future_watcher(m_size_watcher, true);
|
||||
if (from_drive)
|
||||
{
|
||||
gui::utils::stop_future_watcher(m_size_watcher, true, m_size_watcher_cancel);
|
||||
}
|
||||
gui::utils::stop_future_watcher(m_repaint_watcher, true);
|
||||
gui::utils::stop_future_watcher(m_refresh_watcher, from_drive);
|
||||
|
||||
@ -714,7 +717,7 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after)
|
||||
|
||||
void game_list_frame::OnRefreshFinished()
|
||||
{
|
||||
gui::utils::stop_future_watcher(m_size_watcher, true);
|
||||
gui::utils::stop_future_watcher(m_size_watcher, true, m_size_watcher_cancel);
|
||||
gui::utils::stop_future_watcher(m_repaint_watcher, true);
|
||||
|
||||
for (auto&& g : m_games.pop_all())
|
||||
|
@ -2982,6 +2982,10 @@ void main_window::keyPressEvent(QKeyEvent *keyEvent)
|
||||
{
|
||||
ui->toolbar_fullscreen->trigger();
|
||||
}
|
||||
else if ((keyEvent->modifiers() & Qt::ControlModifier) && keyEvent->key() == Qt::Key_F5)
|
||||
{
|
||||
m_game_list_frame->Refresh(true);
|
||||
}
|
||||
}
|
||||
|
||||
void main_window::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "util/types.hpp"
|
||||
#include "util/atomic.hpp"
|
||||
|
||||
#include <QDir>
|
||||
#include <QComboBox>
|
||||
@ -130,13 +131,19 @@ namespace gui
|
||||
QString format_byte_size(usz size);
|
||||
|
||||
template <typename T>
|
||||
void stop_future_watcher(QFutureWatcher<T>& watcher, bool cancel)
|
||||
void stop_future_watcher(QFutureWatcher<T>& watcher, bool cancel, std::shared_ptr<atomic_t<bool>> cancel_flag = nullptr)
|
||||
{
|
||||
if (watcher.isRunning())
|
||||
if (watcher.isStarted() || watcher.isRunning())
|
||||
{
|
||||
if (cancel)
|
||||
{
|
||||
watcher.cancel();
|
||||
|
||||
// We use an optional cancel flag since the QFutureWatcher::canceled signal seems to be very unreliable
|
||||
if (cancel_flag)
|
||||
{
|
||||
*cancel_flag = true;
|
||||
}
|
||||
}
|
||||
watcher.waitForFinished();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user