From 336cd6e33a2479893c9700cd6273fd87da3d18ef Mon Sep 17 00:00:00 2001 From: Megamouse Date: Tue, 28 Jan 2020 22:04:43 +0100 Subject: [PATCH] Qt: Prevent Qt from blocking the explorer during installations --- rpcs3/rpcs3qt/main_window.cpp | 40 ++++++++++++++++++++++++++++------- rpcs3/rpcs3qt/main_window.h | 4 ++++ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 32dfd8e2e8..b42664edcd 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -397,6 +397,18 @@ void main_window::InstallPackages(QStringList file_paths, bool show_confirm) } } + if (!file_paths.isEmpty()) + { + // Handle the actual installations with a timeout. Otherwise the source explorer instance is not usable during the following file processing. + QTimer::singleShot(0, [this, file_paths]() + { + HandlePackageInstallation(file_paths); + }); + } +} + +void main_window::HandlePackageInstallation(QStringList file_paths) +{ if (file_paths.isEmpty()) { return; @@ -490,24 +502,36 @@ void main_window::InstallPackages(QStringList file_paths, bool show_confirm) } } -void main_window::InstallPup(QString filePath) +void main_window::InstallPup(QString file_path) { - if (filePath.isEmpty()) + if (file_path.isEmpty()) { QString path_last_PUP = guiSettings->GetValue(gui::fd_install_pup).toString(); - filePath = QFileDialog::getOpenFileName(this, tr("Select PS3UPDAT.PUP To Install"), path_last_PUP, tr("PS3 update file (PS3UPDAT.PUP);;All pup files (*.pup);;All files (*.*)")); + file_path = QFileDialog::getOpenFileName(this, tr("Select PS3UPDAT.PUP To Install"), path_last_PUP, tr("PS3 update file (PS3UPDAT.PUP);;All pup files (*.pup);;All files (*.*)")); } else { - if (QMessageBox::question(this, tr("RPCS3 Firmware Installer"), tr("Install firmware: %1?").arg(filePath), + if (QMessageBox::question(this, tr("RPCS3 Firmware Installer"), tr("Install firmware: %1?").arg(file_path), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes) { - LOG_NOTICE(LOADER, "Firmware: Cancelled installation from drop. File: %s", sstr(filePath)); + LOG_NOTICE(LOADER, "Firmware: Cancelled installation from drop. File: %s", sstr(file_path)); return; } } - if (filePath.isEmpty()) + if (!file_path.isEmpty()) + { + // Handle the actual installation with a timeout. Otherwise the source explorer instance is not usable during the following file processing. + QTimer::singleShot(0, [this, file_path]() + { + HandlePupInstallation(file_path); + }); + } +} + +void main_window::HandlePupInstallation(QString file_path) +{ + if (file_path.isEmpty()) { return; } @@ -515,8 +539,8 @@ void main_window::InstallPup(QString filePath) Emu.SetForceBoot(true); Emu.Stop(); - guiSettings->SetValue(gui::fd_install_pup, QFileInfo(filePath).path()); - const std::string path = sstr(filePath); + guiSettings->SetValue(gui::fd_install_pup, QFileInfo(file_path).path()); + const std::string path = sstr(file_path); fs::file pup_f(path); if (!pup_f) diff --git a/rpcs3/rpcs3qt/main_window.h b/rpcs3/rpcs3qt/main_window.h index faf63361df..4267f1ef10 100644 --- a/rpcs3/rpcs3qt/main_window.h +++ b/rpcs3/rpcs3qt/main_window.h @@ -117,8 +117,12 @@ private: void CreateDockWindows(); void EnableMenus(bool enabled); void ShowTitleBars(bool show); + void InstallPackages(QStringList file_paths = QStringList(), bool show_confirm = true); + void HandlePackageInstallation(QStringList file_paths = QStringList()); + void InstallPup(QString filePath = ""); + void HandlePupInstallation(QString file_path = ""); int IsValidFile(const QMimeData& md, QStringList* dropPaths = nullptr); void AddGamesFromDir(const QString& path);