util: Use canonicalFilePath to clean the path opened by explorer.

This fixes bug #2299
This commit is contained in:
Klaas Freitag 2014-10-23 10:40:22 +02:00
parent c7c05ea869
commit e726e7aad8

View file

@ -90,18 +90,22 @@ void showInFileManager(const QString &localPath)
} }
#endif #endif
QString explorer = "explorer.exe "; // FIXME: we trust it's in PATH QString explorer = "explorer.exe "; // FIXME: we trust it's in PATH
QFileInfo fi(localPath);
if (!QFileInfo(localPath).isDir()) { // canonicalFilePath returns empty if the file does not exist
explorer += QLatin1String("/select,"); 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()) { } else if (Utility::isMac()) {
QStringList scriptArgs; QStringList scriptArgs;
scriptArgs << QLatin1String("-e") scriptArgs << QLatin1String("-e")
@ -182,4 +186,4 @@ void showInFileManager(const QString &localPath)
} }
} }
} }