Bug 364805 - Gwenview fails to open images with russian letters in path - Invalid url QUrl("") or file or path does not exist
Summary: Gwenview fails to open images with russian letters in path - Invalid url QUrl...
Status: RESOLVED WORKSFORME
Alias: None
Product: gwenview
Classification: Applications
Component: general (show other bugs)
Version: 5.0.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Gwenview Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-27 09:56 UTC by emg81
Modified: 2017-04-20 23:40 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
gwenview - files with russian names (3.06 MB, image/png)
2017-03-14 17:28 UTC, Wadlax
Details
compiled gwenview (642.73 KB, image/png)
2017-03-22 21:11 UTC, Wadlax
Details

Note You need to log in before you can comment on or make changes to this bug.
Description emg81 2016-06-27 09:56:28 UTC
OS: gentoo x86_64
System QT: 4.8.7 and 5.6.1

KDE Frameworks 5.23.0
Gwenview version 16.04.2 built with Qt 5.6.1
(absolutely same behavior with 16.04.1 and 15.02
USE flags: exceptions glib iconv icu qt3support ssl -aqua -debug -libressl -pch

When I try to open image file containing russian (or any non-latin I think) letters in path or filename via dolphin or using terminal I get an error and it's impossible to open file.

Reproducible: Always

Steps to Reproduce:
1. Update Gwenview to 15.* or 16.* versions
2. Try to open file containing russian (or any non-latin I think) letters in path or filename via dolphin or using terminal
3. Receive an error

Actual Results:  
Terminal:
ivan@pc ~/Загрузки $ pwd
/home/ivan/Загрузки
ivan@pc ~/Загрузки $ gwenview 7481768d6a7599.jpg 
Reusing existing ksycoca
Recreating ksycoca file ("/home/ivan/.cache/ksycoca5_ru_5johlaTaFupG6QDGdPq34bH9xx0=", version 303)
Still in the time dict (i.e. deleted files) ("apps")
kf5.kservice.sycoca: Parse error in  "/home/ivan/.config/menus/applications-merged/xdg-desktop-menu-dummy.menu" , line  1 , col  1 :  "unexpected end of file"
kf5.kservice.sycoca: The menu spec file contains a Layout or DefaultLayout tag without the mandatory Merge tag inside. Please fix your file.
Saving
Invalid url QUrl("")

QXcbConnection: XCB error: 3 (BadWindow), sequence: 1318, resource id: 29711394, major code: 40 (TranslateCoords), minor code: 0

And it shows error window with:
Невозможно получить список файлов по URL (which is smth like "Unable to get list of files by URL")
http://7481768d6a7599.jpg

Expected Results:  
Image should be opened correctly

It happens every time since I upgraded to Plasma 5.
Gwenview 4.14.3 works OK.

I checked an old bug:
https://bugs.kde.org/show_bug.cgi?id=186038
Might be the same thing with Qt5 here (cannot check Okular because it's built with 4.8.7 and there's no options I know about).

And it might be not Gwenview bug at all, so I apologize in advance.
Comment 1 Alexander Danilov 2016-08-03 09:28:29 UTC
Gwenview 15.12.3 does not work for me too.
I also experience the same problems with several other apps, e.g. kompare and filelight

Problem with kompare 4.1.3 (KDE Frameworks 5.23.0, Qt 5.6.1 (built against 5.6.1))
$ pwd
/tmp/Проверка
$ head 1.txt 2.txt
==> 1.txt <==
file 1

==> 2.txt <==
file 2
$ kompare 1.txt 2.txt
komparepart: SetXOffset : Scroll to x position:  6
komparepart: SetXOffset : Scroll to x position:  6
libkomparediff: Show me the arguments:  0x8ca580 ,  KompareSplitter(0x884970) ,  KomparePart(0x8846f0) ,  komparemodellist
kompareshell: Arg Count =  2
kompareshell: Argument  1 :  "1.txt"
kompareshell: Argument  2 :  "2.txt"
komparepart: SetXOffset : Scroll to x position:  6
komparepart: SetXOffset : Scroll to x position:  6
komparepart: SetXOffset : Scroll to x position:  6
kompareshell: Dunno, we'll have to figure it out later, trying compare for now...
kompareshell: URL0 =  "file:///tmp/????????????????/1.txt"
kompareshell: URL1 =  "file:///tmp/????????????????/2.txt"
komparepart: SetXOffset : Scroll to x position:  6
komparepart: SetXOffset : Scroll to x position:  6
komparepart: SetXOffset : Scroll to x position:  6
komparepart: SetXOffset : Scroll to x position:  6

Two pop-up dialogs with error messages:
"The URL file:///tmp/����������������/1.txt does not exist on your system."
"The URL file:///tmp/����������������/2.txt does not exist on your system."

Problem with filelight 1.21 (KDE Frameworks 5.23.0, Qt 5.6.1 (built against 5.6.1))
$ pwd
/tmp/Проверка
$ filelight  .

Pop-up dialog with information:
"Folder not found: /tmp/????????????????"

Okular works fine for me, but its version is 0.24.2, and it is using KDE 4.14.20, i.e. not KDE 5.

Most other KDE 5 apps works ok with non-unicode characters in the path, e.g. ark, dolphin, kate, kwrite
Comment 2 Alexander Danilov 2017-01-18 09:37:49 UTC
Adding to my previous report.

Gwenview 16.08.3 (KDE Frameworks 5.29.0, Qt 5.6.2) is working all good as expected.
Kompare-4.1.3 and filelight-1.21 are now working as well.

It looks like either KDE Frameworks update 5.23.0 -> 5.29.0, or Qt update 5.6.1 -> 5.6.2 fixed the problem.
Comment 3 emg81 2017-01-26 22:22:04 UTC
Still doesn't work here with:

Gwenview 16.12.1
KDE Frameworks 5.30.0
Qt 5.7.1 (built against 5.7.1)
Comment 4 Christoph Feck 2017-01-30 21:18:16 UTC
Which locale do you use? If the locale uses UTF-8 encoding, are you sure all filenames are correctly UTF-8 encoded? If unsure, try the 'convmv' tool to check and correct the encoding of filenames.

https://linux.die.net/man/1/convmv
Comment 5 emg81 2017-02-09 00:30:43 UTC
(In reply to Christoph Feck from comment #4)
> Which locale do you use? If the locale uses UTF-8 encoding, are you sure all
> filenames are correctly UTF-8 encoded? If unsure, try the 'convmv' tool to
> check and correct the encoding of filenames.
> 
> https://linux.die.net/man/1/convmv

Thanks for answer.

I've tried this tool. Seems that everything is UTF-8 so far
ivan@pc ~ $ convmv -f UTF-8 -t UTF-8 -r ~/
Starting a dry run without changes...
WARNING: cannot traverse /home/ivan/.subversion/auth
WARNINGS occurred. Do you really want to continue? (y/n) y

No changes to your files done. Would have converted 0 files in 27 seconds.
Use --notest to finally rename the files.
Comment 6 Christoph Feck 2017-02-09 20:47:35 UTC
If you change from UTF-8 to UTF-8 no changes will be made. Please use a different -f encoding, convmv will automatically skip files that are already UTF-8.

For example, if the files you are trying to view come from old unzip, the filenames are usually "latin1" encoded. For Cyrillic names, try "koi8r" or "koi8u". https://en.wikipedia.org/wiki/Cyrillic_script#Computer_encoding section "Other" lists more encodings.

> convmv -f latin1 -t utf8 -r ~/
Starting a dry run without changes...
Skipping, already UTF-8: /home/pepo/gedämpfte-schwingung.fkt
Skipping, already UTF-8: /home/pepo/.cache/favicons/åc.dk.png
No changes to your files done. Would have converted 0 files in 5 seconds.
Use --notest to finally rename the files.
Comment 7 emg81 2017-02-11 23:58:33 UTC
Thanks for reply and advices.

Tried all of those.
Everything ends up with:

"No changes to your files done. Would have converted 0 files in 21 seconds.
Use --notest to finally rename the files."

So i've tried to convert filename with convmv to koi8u and then convert it back to UTF8 to make sure it's UTF8.

ivan@pc ~ $ convmv -f utf8 -t koi8u картинка1.jpg --notest
mv "./картинка1.jpg"    "./��������1.jpg"
Ready! I converted 1 files in 0 seconds.

ivan@pc ~ $ convmv -f koi8u -t utf8 *.jpg --notest
mv "./��������1.jpg"    "./картинка1.jpg"
Ready! I converted 1 files in 0 seconds.

And it didn't help. 
I've got the same error when trying graphic interface and same error with message Invalid url QUrl("") when trying shell.

Gwenview 16.12.2
KDE Frameworks 5.31.0,
Qt 5.7.1 (built with 5.7.1),
Comment 8 Christoph Feck 2017-02-22 17:01:21 UTC
Okey. I'm out of ideas. On my system, Gwenview can open files with any Unicode characters, I even tried non-BMP characters like Emoticons.

Also, I did not spot any wrong encoding conversion calls in Gwenview source, it uses QString and QUrl throughout.
Comment 9 Wadlax 2017-03-14 17:28:56 UTC
Created attachment 104566 [details]
gwenview - files with russian names
Comment 10 Wadlax 2017-03-14 17:31:54 UTC
I do not complain, since it's needed to be tested with clean kde prefix.
(But in kde4 all worked good :) )
I attached a screen - please see it.

Hope it may help.

I run Gentoo, have Gwenview 16.12.3 , qtcore 4.8.7-r2 and 5.7.1-r1
Comment 11 Wadlax 2017-03-14 18:07:23 UTC
I have tried new user (with a clean home dir) and No, problem still exists for me.
Comment 12 Wadlax 2017-03-22 21:10:38 UTC
Christoph Feck, what qt version do you have?
 
I have found a pattern in this error.
Gwenview can be fixed, but i think that problem may be related to qt, as in bug https://bugs.kde.org/show_bug.cgi?id=186038
 
.
 
Pattern in source code:
Some programms , that does not understand russian letters (in my system) call "KLocalizedString::setApplicationDomain....." prior to QApplication app(argc, argv);"

Not working - for example - Gwenview, KTorrent

.

Programms, that have "QApplication app(argc, argv);" first and "KLocalizedString::setApplicationDomain("<prog_name>");" later - show russian chars for me.

Working - example - dolphin, okular

.

So, i have installed KDevelop, downloaded Gwenview git sources.

1st compile and run - same error - russian chars do not recognized.

2nd - moved line "QApplication app(argc, argv);" before line "KLocalizedString::setApplicationDomain("gwenview");"
and programm work good.

(I dont know C++ very well, so i cannot debug deeper - to find common place of problem)

.

Attaching screen.
Bottom right - two compiled gwenview - showing "russian" folder and "russian" filenames - working as desired.

.

Hope this will help to find a main bug, common to all apps.
Comment 13 Wadlax 2017-03-22 21:11:59 UTC
Created attachment 104692 [details]
compiled gwenview
Comment 14 Wadlax 2017-04-03 17:41:07 UTC
Error was specific to my locale settings.
 
I had line  LC_ALL=""   in file  /etc/env.d/02locale

Can anyone affected check this file?
Comment 15 Luigi Toscano 2017-04-12 20:50:34 UTC
(In reply to Wadlax from comment #14)
> Error was specific to my locale settings.
>  
> I had line  LC_ALL=""   in file  /etc/env.d/02locale
> 
> Can anyone affected check this file?

So basically now you have LC_ALL="ru_RU.UTF-8", or something like that, and gwenview works as it is?
Comment 16 Wadlax 2017-04-13 08:30:14 UTC
My current /etc/env.d/02local:
LANG="ru_RU.utf8"
LC_NUMERIC="POSIX"


As Gentoo wiki says:

Using LC_ALL is strongly discouraged as it automatically overrides all other LC_* variables (LANG is not affected).
This means that changes made by other means will be hidden until LC_ALL is set to a null string.
It is probably best not to set it in a startup file. <----- This

---

Probably KDE use LC_MESSAGES (Programs' localizations stored in /usr/share/locale/ for application...)

If LC_ALL="" then LC_MESSAGES="" => wrong locale.
Comment 17 Wadlax 2017-04-13 08:42:56 UTC
"gwenview works as it is?"

Yes, system gwenview works well.
And not only gwenview - konsole, KTorrent had problems with non-latin chars (not only russian).
Now all is good.

.

As i said in comment 12 - if programm had

"QApplication app(argc, argv);" first and "KLocalizedString::setApplicationDomain("<prog_name>");" later

it worked good even with LC_ALL=""

.

Anyways - i consider setting right locale - a right way.
(was fooled by "it just worked in KDE4 with LC_ALL="")
Comment 18 emg81 2017-04-14 19:43:42 UTC
Thanks to you all for help in solving this issue.

Wadlax's solution worked for me

I just did the same thing to /etc/env.d/02local:
--
LANG="ru_RU.utf8"
LC_NUMERIC="POSIX"
--
And it works like a charm now.

Thanks, Wadlax, appreciated.