From e726e7aad840628f9f432560146abeb6752ca0ba Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Thu, 23 Oct 2014 10:40:22 +0200 Subject: [PATCH] util: Use canonicalFilePath to clean the path opened by explorer. This fixes bug #2299 --- src/mirall/openfilemanager.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/mirall/openfilemanager.cpp b/src/mirall/openfilemanager.cpp index 397c5c56a..698cc3dd9 100644 --- a/src/mirall/openfilemanager.cpp +++ b/src/mirall/openfilemanager.cpp @@ -90,18 +90,22 @@ void showInFileManager(const QString &localPath) } #endif QString explorer = "explorer.exe "; // FIXME: we trust it's in PATH + QFileInfo fi(localPath); - if (!QFileInfo(localPath).isDir()) { - explorer += QLatin1String("/select,"); + // canonicalFilePath returns empty if the file does not exist + if( !fi.canonicalFilePath().isEmpty() ) { + if (!fi.isDir()) { + explorer += QLatin1String("/select,"); + } + explorer += QLatin1Char('"'); + explorer += QDir::toNativeSeparators(fi.canonicalFilePath()); + explorer += QLatin1Char('"'); + + qDebug() << "OO Open explorer commandline:" << explorer; + QProcess p; + p.start(explorer); + p.waitForFinished(5000); } - explorer += QLatin1Char('"'); - explorer += QDir::toNativeSeparators(localPath); - explorer += QLatin1Char('"'); - - qDebug() << "OO Open explorer commandline:" << explorer; - QProcess p; - p.start(explorer); - p.waitForFinished(5000); } else if (Utility::isMac()) { QStringList scriptArgs; scriptArgs << QLatin1String("-e") @@ -182,4 +186,4 @@ void showInFileManager(const QString &localPath) } } -} \ No newline at end of file +}