Commit 1189583d authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark Committed by Jean-Baptiste Mardelle
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:
parent 8984bf80
......@@ -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());
Core::build(!parser.value(QStringLiteral("config")).isEmpty(), parser.value(QStringLiteral("mlt-path")));
Supports Markdown
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