Bug 205076 - okular: inconsistent handling of reference given as part of command line arg
Summary: okular: inconsistent handling of reference given as part of command line arg
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
: 226764 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-08-25 14:22 UTC by Jochen Trumpf
Modified: 2010-02-22 21:06 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch file to fix url encoding in okular (1.20 KB, patch)
2009-12-25 09:11 UTC, Jochen Trumpf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jochen Trumpf 2009-08-25 14:22:26 UTC
Version:            (using Devel)
Compiler:          gcc (Gentoo 4.3.2-r3 p1.6, pie-10.1.5) 4.3.2 
OS:                Linux
Installed from:    Compiled sources

The "cut and paste work" in the Shell constructor has fixed handling of the reference part of an (incomplete) "url" given on the command line, such as 

okular test.dvi#src:13test.tex

for me. However, if the --unique switch is used and okular is already running, no new Shell is constructed (obviously) but the document is opened via dbus and Part::openDocument( const QString &doc ). Here, the string doc is converted to a url using a simple KUrl constructor. In this process, the '#' is encoded as %23 and the openUrl call fails.

So,

okular --unique test.dvi#src:13test.tex

followed by 

okular --unique test.dvi#src:13test.tex

opens the document correctly but gives an error for the second call.
Before you say this is a feature ;-), consider the following:

okular --unique file:///full/path/test.dvi#src:13test.tex

followed by 

okular --unique file:///full/path/test.dvi#src:13test.tex

works just fine*! If the url is fully qualified, the KUrl constructor recognises the '#' and splits off the reference. 
I am not sure what the best way of fixing this is. Simply taking the "cut and paste" code from the Shell constructor and using it in Part::openDocument works for me (with the obvious modifications), but this seems an ugly solution (code duplication).

* actually, there is a separate (very tricky) bug in the actual handling of source references which I will report separately
Comment 1 Jochen Trumpf 2009-08-25 15:11:19 UTC
The other bug is bug #205084.

Cheers, Jochen
Comment 2 Jochen Trumpf 2009-12-25 09:11:45 UTC
Created attachment 39324 [details]
patch file to fix url encoding in okular

Okay, unless someone has a better idea, how about adding this hotfix in the meantime (see attached patch)? It is duplicating code from ShellUtils (which appears not to be accessible from this context), but at least it solves this annoying bug and makes using source-references together with --unique less painful ...
Comment 3 Albert Astals Cid 2009-12-28 21:46:35 UTC
Does this one work?

Index: shell/main.cpp
===================================================================
--- shell/main.cpp      (revision 1067040)
+++ shell/main.cpp      (working copy)
@@ -18,6 +18,7 @@
 #include <klocale.h>
 #include <QtDBus/qdbusinterface.h>
 #include "aboutdata.h"
+#include "shellutils.h"

 static bool attachUniqueInstance(KCmdLineArgs* args)
 {
@@ -28,7 +29,7 @@
     if (!iface.isValid())
         return false;

-    iface.call("openDocument", args->url(0).pathOrUrl());
+    iface.call("openDocument", ShellUtils::urlFromArg(args->arg(0), ShellUtils::qfileExistFunc()).url());

     return true;
 }
Comment 4 Jochen Trumpf 2009-12-29 02:00:24 UTC
Yep, that one works for me and is much more elegant than my attempt. I'll consider this bug fixed once you have committed the change. Thanks.
Comment 5 Albert Astals Cid 2009-12-29 09:38:52 UTC
SVN commit 1067205 by aacid:

Do the same treatment to paths passed from the command line
when we are starting a new shell and when we are passing the argument
through dbus
BUGS: 205076


 M  +2 -1      main.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1067205
Comment 6 Albert Astals Cid 2010-02-22 21:06:04 UTC
*** Bug 226764 has been marked as a duplicate of this bug. ***