From f894e2b9a216dcce1e2a9c9ff7bc83bee1b44a61 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 7 Jan 2023 11:58:16 +0100 Subject: [PATCH] Qt: Fix open_dir for paths with multiple slashes --- rpcs3/rpcs3qt/qt_utils.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rpcs3/rpcs3qt/qt_utils.cpp b/rpcs3/rpcs3qt/qt_utils.cpp index 556b94a5da..23719eff58 100644 --- a/rpcs3/rpcs3qt/qt_utils.cpp +++ b/rpcs3/rpcs3qt/qt_utils.cpp @@ -397,17 +397,18 @@ namespace gui void open_dir(const std::string& spath) { - const QString path = qstr(spath); + QString path = qstr(spath); if (fs::is_file(spath)) { // open directory and select file // https://stackoverflow.com/questions/3490336/how-to-reveal-in-finder-or-show-in-explorer-with-qt #ifdef _WIN32 - const QString cleaned_path = QDir::toNativeSeparators(path); - gui_log.notice("gui::utils::open_dir: About to open file path '%s' (original: '%s')", cleaned_path.toStdString(), spath); + // Remove double slashes and convert to native separators. Double slashes don't seem to work with the explorer call. + path.replace(QRegularExpression("[\\\\|/]+"), QDir::separator()); + gui_log.notice("gui::utils::open_dir: About to open file path '%s' (original: '%s')", path.toStdString(), spath); - if (!QProcess::startDetached("explorer.exe", {"/select,", cleaned_path})) + if (!QProcess::startDetached("explorer.exe", {"/select,", path})) { gui_log.error("gui::utils::open_dir: Failed to start explorer process"); }