Qt: make sure the gamelist refresh progress dialog runs on the main thread

This commit is contained in:
Megamouse 2024-03-09 17:54:35 +01:00
parent ee69468104
commit 4a7d982a2b
1 changed files with 15 additions and 2 deletions

View File

@ -316,8 +316,21 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after)
m_games.pop_all();
m_progress_dialog = new progress_dialog(tr("Loading games"), tr("Loading games, please wait..."), tr("Cancel"), 0, 0, true, this, Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
connect(&m_refresh_watcher, &QFutureWatcher<void>::progressRangeChanged, m_progress_dialog, &QProgressDialog::setRange);
connect(&m_refresh_watcher, &QFutureWatcher<void>::progressValueChanged, m_progress_dialog, &QProgressDialog::setValue);
connect(&m_refresh_watcher, &QFutureWatcher<void>::progressRangeChanged, this, [this](int minimum, int maximum)
{
if (m_progress_dialog)
{
m_progress_dialog->SetRange(minimum, maximum);
}
}, Qt::QueuedConnection);
connect(&m_refresh_watcher, &QFutureWatcher<void>::progressValueChanged, this, [this](int value)
{
if (m_progress_dialog)
{
m_progress_dialog->SetValue(value);
}
}, Qt::QueuedConnection);
connect(m_progress_dialog, &QProgressDialog::canceled, this, [this]()
{
gui::utils::stop_future_watcher(m_parsing_watcher, true);