Commit 3ec9dbed authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark
Browse files

Fix opening relative paths from the command line

The code didn't work as intended, and somewhere something was calling
QUrl::fromUserInput() when adding to recently used documents. And that
helpfully adds "http:" as scheme if none is set (e. g. if opening a
relative file). So a lot of things broke.

Test Plan: Opening relative paths from the command line works again

Differential Revision: https://phabricator.kde.org/D28628
parent 1e17bb9e
Pipeline #17945 passed with stage
in 8 minutes and 53 seconds
......@@ -243,11 +243,12 @@ int main(int argc, char *argv[])
const QString clipsToLoad = parser.value(QStringLiteral("i"));
QUrl url;
if (parser.positionalArguments().count() != 0) {
url = QUrl::fromLocalFile(parser.positionalArguments().at(0));
// Make sure we get an absolute URL so that we can autosave correctly
QString currentPath = QDir::currentPath();
QUrl startup = QUrl::fromLocalFile(currentPath.endsWith(QDir::separator()) ? currentPath : currentPath + QDir::separator());
url = startup.resolved(url);
const QString inputFilename = parser.positionalArguments().at(0);
const QFileInfo fileInfo(inputFilename);
url = QUrl(inputFilename);
if (fileInfo.exists() || url.scheme().isEmpty()) { // easiest way to detect "invalid"/unintended URLs is no scheme
url = QUrl::fromLocalFile(fileInfo.absoluteFilePath());
}
}
qApp->processEvents(QEventLoop::AllEvents);
Core::build(!parser.value(QStringLiteral("config")).isEmpty(), parser.value(QStringLiteral("mlt-path")));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment