From 154c98fdaab2e593091fe644cfaeed96dd9fefaf Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Fri, 26 Feb 2016 17:04:40 +0100 Subject: [PATCH] Fix QUrl string encoding issue Don't go through QUrl -> QString -> QUrl when opening files from the argument list. Don't be strict when opening URLs that come from the dbus interface. REVIEW: 127042 --- shell/okular_main.cpp | 3 ++- shell/shell.cpp | 9 +++++++-- shell/shell.h | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/shell/okular_main.cpp b/shell/okular_main.cpp index 9bdc1feed..2285f64a9 100644 --- a/shell/okular_main.cpp +++ b/shell/okular_main.cpp @@ -166,7 +166,8 @@ Status main(const QStringList &paths, const QString &serializedOptions) { // Page only makes sense if we are opening one file const QString page = ShellUtils::page(serializedOptions); - if ( shell->openDocument( ShellUtils::urlFromArg(paths[i], ShellUtils::qfileExistFunc(), page).url(), serializedOptions) ) + const QUrl url = ShellUtils::urlFromArg(paths[i], ShellUtils::qfileExistFunc(), page); + if ( shell->openDocument( url, serializedOptions) ) { ++i; } diff --git a/shell/shell.cpp b/shell/shell.cpp index c97054afc..60b22eac3 100644 --- a/shell/shell.cpp +++ b/shell/shell.cpp @@ -188,7 +188,7 @@ Shell::~Shell() // Open a new document if we have space for it // This can hang if called on a unique instance and openUrl pops a messageBox -bool Shell::openDocument( const QString& urlString, const QString &serializedOptions ) +bool Shell::openDocument( const QUrl& url, const QString &serializedOptions ) { if( m_tabs.size() <= 0 ) return false; @@ -203,11 +203,16 @@ bool Shell::openDocument( const QString& urlString, const QString &serializedOpt return false; } - openUrl( QUrl( urlString, QUrl::StrictMode) , serializedOptions ); + openUrl( url, serializedOptions ); return true; } +bool Shell::openDocument( const QString& urlString, const QString &serializedOptions ) +{ + return openDocument(QUrl(urlString), serializedOptions); +} + bool Shell::canOpenDocs( int numDocs, int desktop ) { if( m_tabs.size() <= 0 || numDocs <= 0 || m_unique ) diff --git a/shell/shell.h b/shell/shell.h index c7c155b2e..a6b9479d6 100644 --- a/shell/shell.h +++ b/shell/shell.h @@ -67,6 +67,8 @@ public: **/ bool isValid() const; + bool openDocument(const QUrl &url, const QString &serializedOptions); + public slots: Q_SCRIPTABLE Q_NOREPLY void tryRaise(); Q_SCRIPTABLE bool openDocument(const QString &urlString, const QString &serializedOptions = QString() );