Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

PDF open problem



  • After an ubuntu 16.04 upgrade. the openURL, doesn't work.

    QString homePath = QDir::homePath();
    QDesktopServices::openUrl(QUrl(homePath + "/... .pdf"));

    I have this error:

    Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/%{ <-- HERE (.*?)}/ at /usr/bin/run-mailcap line 528.
    No protocol specified
    Failed to connect to Mir: Failed to connect to server socket: Aucun fichier ou dossier de ce type
    Unable to init server: Impossible de se connecter : Connexion refusée
    Cannot parse arguments: Impossible d'ouvrir l'affichage :
    Warning: program returned non-zero exit code #1
    Opening "/home/labotdd/doc3.pdf" with Document Viewer (application/pdf)
    No protocol specified
    Failed to connect to Mir: Failed to connect to server socket: Aucun fichier ou dossier de ce type
    Unable to init server: Impossible de se connecter : Connexion refusée
    Cannot parse arguments: Impossible d'ouvrir l'affichage :
    Running Firefox as root in a regular user's session is not supported. ($HOME is /home/labotdd which is owned by labotdd.)
    Running Firefox as root in a regular user's session is not supported. ($HOME is /home/labotdd which is owned by labotdd.)
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: iceweasel: not found
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: seamonkey: not found
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: mozilla: not found
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: epiphany: not found
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: konqueror: not found
    [17836:17836:0719/165325.163206:ERROR:zygote_host_impl_linux.cc(88)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: google-chrome: not found
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: www-browser: not found
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: links2: not found
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: elinks: not found
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: links: not found
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: lynx: not found
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: w3m: not found
    xdg-open: no method available for opening '/home/labotdd/doc3.pdf'

    Any body have a solution or another way to open an external PDF file?

    thanks


  • Lifetime Qt Champion

    Hi
    What happens if you just go and double click the pdf ?
    It seems that your upgrade broke something in the distro.



  • the file is normally opened...
    I also tried to use xdg-open mypdf.pdf and the pdf file has been opened


  • Lifetime Qt Champion

    @f.lerdino
    What Qt is it ?
    Sounds like QDesktopServices broke with update then.
    ( not QDesktopServices faults but something changed in the system)



  • @mrjj
    The final error reads:

    xdg-open: no method available for opening '/home/labotdd/doc3.pdf'

    I don't see how QDesktopServices per se can be blamed for that?

    @f-lerdino
    There are mentions of "root" in the trace. Just to check: you have no root-ness going on when you run the Qt app vs when you do it outside of Qt?

    I also tried to use xdg-open mypdf.pdf and the pdf file has been opened

    Please try with xdg-open /home/labotdd/doc3.pdf

    Also, FWIW, can you try from your Qt app with something other than a .pdf, if your code allows it?



  • for mrjj : I have 5.11.1 and ubuntu 16.04 -kernel 4.13.0.-45.
    for JonB: if I try ro run this 'xdg-open /home/labotdd/doc3.pdf the pdf' the file is opened whitout any problem.



  • @JonB said in PDF open problem:

    Also, FWIW, can you try from your Qt app with something other than a .pdf, if your code allows it?

    I have tried with a txt file and with it works....



  • @f.lerdino
    Root-ness? Do you have anything root-y going on? By any chance, is your Qt app being run as/by root?

    Is your Qt app a GUI one or command-line only? Are you running Unity or not/other?


  • Lifetime Qt Champion

    Hi
    Also could you list what
    xdg-mime query default application/pdf
    returns ?



  • @mrjj said in PDF open problem:

    xdg-mime query default application/pdf

    labotdd@D7050:/opt/Qt/Tools/QtCreator/bin$ xdg-mime query default application/pdf
    evince.desktop


  • Lifetime Qt Champion

    Ok. so that is not changed.
    if u type evince in a shell ( normal user) it starts as normally ?



  • @f.lerdino
    I really think this could be a root issue, which you have not answered. If I deliberately go

    sudo xdg-open .....pdf
    

    I get messages like I see in yours:

    No protocol specified
    Unable to init server: Could not connect: Connection refused
    Cannot parse arguments: Cannot open display: 
    No protocol specified
    Unable to init server: Could not connect: Connection refused
    Cannot parse arguments: Cannot open display: 
    Warning: program returned non-zero exit code #1
    


  • @f.lerdino
    I think this is not a Qt issue per se, but an Ubuntu 16.04 one. Try Googling for something like ubuntu 16.04 xdg-open. I think https://askubuntu.com/questions/779717/xdg-open-stopped-working-since-16-04-upgrade might be where you'll find what you need to do... ?



  • @mrjj
    I have an old version of ubuntu and everything work. Something is changed after the ubuntu update. Of course I run my QT Program as root.


  • Lifetime Qt Champion

    @f.lerdino
    The link @JonB gives , suggest that
    gvfs-info being deprecated.
    so that might be your actual issue.
    (some posts down)



  • @JonB
    I use root to run my Qt program


  • Lifetime Qt Champion

    @f.lerdino
    but does it work then if u dont run as root ?



  • @f.lerdino

    I use root to run my Qt program

    Scary. Which is why I asked earlier.

    Given that the error messages you show are complaining as not being able to do stuff as root, I presume when you tested running the xdg-opens and said they worked you did so as root too?



  • @JonB said in PDF open problem:

    Given that the error messages you show are complaining as not being able to do stuff as root, I presume when you tested running the xdg-opens and said they worked you did so as root too?

    Yes I have tried as root...



  • Can I run as external program the pdf viewer + mypdffile in QT/Ubuntu?

    Thanks


  • Lifetime Qt Champion

    @f.lerdino
    Well you could run it via QProcess.



  • I have the same problem and it seems like the problem is caused by this firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?format=default&id=1323302
    (and the resulting change: https://hg.mozilla.org/mozilla-central/rev/90a06cdcb48f)

    It seems like xdg-open uses firefox in background to display the PDF files.

    Unfortunately it seems like the firefox team has not provided a possibility to bypass this behavior.
    (Chrome Browser for example provides "--no-sandbox" option to start it as root in a non-root user session)


Log in to reply