Qt: make sure to actually delete the progress dialog when it is closed

Also add some more cleanup code for the gamelist refresh progress dialog
This commit is contained in:
Megamouse 2024-03-09 17:57:27 +01:00
parent 4a7d982a2b
commit a09900a64f
2 changed files with 25 additions and 4 deletions

View File

@ -301,8 +301,8 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after)
if (m_progress_dialog)
{
m_progress_dialog->SetValue(m_progress_dialog->maximum());
m_progress_dialog->accept();
m_progress_dialog->deleteLater();
m_progress_dialog = nullptr;
}
@ -331,6 +331,27 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after)
m_progress_dialog->SetValue(value);
}
}, Qt::QueuedConnection);
connect(&m_refresh_watcher, &QFutureWatcher<void>::finished, this, [this]()
{
if (m_progress_dialog)
{
m_progress_dialog->SetValue(m_progress_dialog->maximum());
m_progress_dialog->accept();
m_progress_dialog = nullptr;
}
}, Qt::QueuedConnection);
connect(&m_refresh_watcher, &QFutureWatcher<void>::canceled, this, [this]()
{
if (m_progress_dialog)
{
m_progress_dialog->accept();
m_progress_dialog = nullptr;
}
}, Qt::QueuedConnection);
connect(m_progress_dialog, &QProgressDialog::finished, this, [this]()
{
m_progress_dialog = nullptr;
});
connect(m_progress_dialog, &QProgressDialog::canceled, this, [this]()
{
gui::utils::stop_future_watcher(m_parsing_watcher, true);
@ -348,7 +369,6 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after)
m_progress_dialog_timer->stop();
}
m_progress_dialog->deleteLater();
m_progress_dialog = nullptr;
});
@ -826,8 +846,8 @@ void game_list_frame::OnRefreshFinished()
if (m_progress_dialog)
{
m_progress_dialog->SetValue(m_progress_dialog->maximum());
m_progress_dialog->accept();
m_progress_dialog->deleteLater();
m_progress_dialog = nullptr;
}

View File

@ -51,7 +51,8 @@ void progress_dialog::SetValue(int progress)
void progress_dialog::SetDeleteOnClose()
{
connect(this, &QProgressDialog::canceled, this, &QProgressDialog::deleteLater);
setAttribute(Qt::WA_DeleteOnClose);
connect(this, &QProgressDialog::canceled, this, &QProgressDialog::close, Qt::UniqueConnection);
}
void progress_dialog::SignalFailure() const