From 1a87fbb7f0b943e71e04c7f413a4522959d7e063 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 27 Aug 2024 14:16:22 +0200 Subject: [PATCH] Utils: Fix showing of directories in a graphical shell on Linux In case a directory was passed to FileUtils::showInGraphicalShell, the parent directory was shown in the graphical shell. This fixes it in substituteFileBrowserParameters. Change-Id: Idedd62fabb233b7622561a0e942b1b762513cd6d Reviewed-by: hjk --- src/libs/utils/unixutils.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/utils/unixutils.cpp b/src/libs/utils/unixutils.cpp index f0a7bbf0a13..9a4b3b0f840 100644 --- a/src/libs/utils/unixutils.cpp +++ b/src/libs/utils/unixutils.cpp @@ -49,7 +49,10 @@ QString substituteFileBrowserParameters(const QString &pre, const QString &file) c = pre.at(++i); QString s; if (c == QLatin1Char('d')) { - s = QLatin1Char('"') + QFileInfo(file).path() + QLatin1Char('"'); + // In case a directory was passed in, use that. In case of a file, the parent dir. + const QFileInfo fi(file); + const QString folder = fi.isDir() ? fi.filePath() : fi.path(); + s = QLatin1Char('"') + folder + QLatin1Char('"'); } else if (c == QLatin1Char('f')) { s = QLatin1Char('"') + file + QLatin1Char('"'); } else if (c == QLatin1Char('n')) {