Bug 361973

Summary: File open/save/export dialogs broken
Product: [Applications] krita Reporter: Ilya V. Portnov <portnov>
Component: File formatsAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: halla
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Export file dialog example
Full stderr log

Description Ilya V. Portnov 2016-04-19 18:50:35 UTC
Compiled from git master today.
Debian testing/unstable.

When I call File -> Open, Save, Export, the file dialog:
1. Does not show anything in file list pane, whatever I select in "files type" combobox.
2. Shows only some file types available for export to.

Reproducible: Always

Steps to Reproduce:
1. Launch krita
2. draw something
3. go to file -> export or file -> save
Comment 1 Ilya V. Portnov 2016-04-19 18:51:45 UTC
Created attachment 98466 [details]
Export file dialog example

Selected directory actually contains a lot of files in different formats.
Comment 2 Ilya V. Portnov 2016-04-19 18:52:44 UTC
Fragment of stderr output:

("image/webp", "image/x-r16", "image/x-xbitmap", "image/openraster", "text/x-qml", "image/tiff", "application/x-extension-exr", "image/png", "image/vnd.adobe.photoshop", "image/x-gimp-brush", "text/csv", "image/vnd.microsoft.icon", "image/x-portable-bitmap", "image/bmp", "application/x-krita", "image/x-portable-pixmap", "image/jpeg", "image/x-gimp-brush-animated", "image/x-exr", "image/x-tga", "image/x-xpixmap", "image/x-portable-graymap", "application/x-spriter", "image/jp2", "image/x-r8")
No file found for ".xml" , even though update-mime-info said it would exist.
Either it was just removed, or the directory doesn't have executable permission...
Comment 3 Ilya V. Portnov 2016-04-19 18:56:09 UTC
Created attachment 98467 [details]
Full stderr log

Attaching full log from stdout&stderr. 

The desktop environment is not KDE, but Dolphin (5) launches and works very well, and shows all thumbnails.
Comment 4 Halla Rempt 2016-04-20 06:07:01 UTC
Which desktop environment are you using? There are three dialogs possible on Linux, the GTK, Qt and KDE one, and all have different bugs.
Comment 5 Ilya V. Portnov 2016-04-20 13:54:10 UTC
This is "self-made" desktop environment. I use XMonad as WM, some KDE apps and some GTK apps. Also, I have XDG_CURRENT_DESKTOP=KDE.
Comment 6 Ilya V. Portnov 2016-04-20 13:54:58 UTC
I can't say exactly which dialog is used - it may be Qt's or KDE's one.
Comment 7 Halla Rempt 2016-04-20 13:59:50 UTC
The XDG setting means the KDE dialog is selected -- I wonder whether that works. In any case, I'm trying to reproduce and debug.
Comment 8 Ilya V. Portnov 2016-04-20 15:47:21 UTC
Git revision bae990e... is "good", file dialog works in it.
It seems I have to do git bisect, but building krita each time takes so much time... :/
Comment 9 Ilya V. Portnov 2016-04-20 18:57:27 UTC
So, I finally run git bisect, and the result is:

5ef533050cd4206353b44fecd4f06edd6e94e729 is the first bad commit
commit 5ef533050cd4206353b44fecd4f06edd6e94e729
Author: Boudewijn Rempt <boud@valdyas.org>
Date:   Wed Apr 6 20:57:52 2016 +0200

    Find all the languages so the language chooser is shown
    
    Make sure that on all platforms the local xdg_data_dirs is part
    of the environment variable, the one that is bin'../share or
    MacOS/../share.
    
    And remove the kauthorized stuff as well. Nobody is going to disable
    anything in the help menu in krita in any kind of kiosk situation.

:040000 040000 1daa8888b4b1c7328743631461c0f7dc61e61905 b89d6b0304263dda7fc9a7ccb4fc14c3f248b00e M      libs
Comment 10 Ilya V. Portnov 2016-04-20 19:02:17 UTC
"Suspected" part of that commit is

+    #ifdef Q_OS_LINUX
+    qputenv("XDG_DATA_DIRS", QFile::encodeName(KoResourcePaths::getApplicationRoot() + "/share") + ":" + qgetenv("XDG_DATA_DIRS"));
+#else
+    qputenv("XDG_DATA_DIRS", QFile::encodeName(KoResourcePaths::getApplicationRoot() + "/share"));
+#endif
+    //qDebug() << "Setting XDG_DATA_DIRS" << qgetenv("XDG_DATA_DIRS");
 
In my environment, I have XDG_DATA_DIRS not set.
Comment 11 Ilya V. Portnov 2016-04-24 16:34:35 UTC
Well, following is pretty simple patch against git master which resolves the bug in my case:

diff --git a/krita/main.cc b/krita/main.cc
index 7f79ddf..d1752dc 100644
--- a/krita/main.cc
+++ b/krita/main.cc
@@ -112,7 +112,7 @@ extern "C" int main(int argc, char **argv)
     KisApplication app(key, argc, argv);
 
 #ifdef Q_OS_LINUX
-    qputenv("XDG_DATA_DIRS", QFile::encodeName(KoResourcePaths::getApplicationRoot() + "share") + ":" + qgetenv("XDG_DATA_DIRS"));
+    //qputenv("XDG_DATA_DIRS", QFile::encodeName(KoResourcePaths::getApplicationRoot() + "share") + ":" + qgetenv("XDG_DATA_DIRS"));
 #else
     qputenv("XDG_DATA_DIRS", QFile::encodeName(KoResourcePaths::getApplicationRoot() + "share"));
 #endif
Comment 12 Halla Rempt 2016-04-25 08:21:59 UTC
But we cannot just not set that because that means the translations cannot be found. And I don't get how this can break the KDE file dialog either...
Comment 13 Ilya V. Portnov 2016-04-25 12:30:31 UTC
I think it depends somehow on DE running. Maybe KDE sets XDG_DATA_DIRS somehow.
On my configuration XDG_DATA_DIRS is not set and everything works somehow.
It may be also important that I install krita by running make install with custom installation directory (smth like /home/portnov/soft/krita).
Comment 14 Halla Rempt 2016-04-29 13:04:26 UTC
I still don't know what's up, but the only way I can reproduce it is in a fedora 23 live session. The file dialog is completely broken there.
Comment 15 Halla Rempt 2016-05-02 10:41:43 UTC
Git commit 2b35122a513c062a28e302e86c6c5d18cdb3d594 by Boudewijn Rempt.
Committed on 02/05/2016 at 10:41.
Pushed by rempt into branch 'master'.

Remove the shared mime dir when packaging

On Redhat-based distributions, having an extra mime dir in the
XDG_DATA_DIRS confuses the file dialog into not being able to
retrieve any mimetype. Is it a Qt bug? Is it a Redhat bug? I
don't know, but removing the mimedir makes everything work again,
and we don't use our own mimetype definitions anyway, we have
a fallback for them because QMimeDatabase is too stupid to allow
us to add mimetypes programmatically.

We still want to install our own mimetypes, or rather, I suspect
distributions want us to, so we cannot just skip that. But if
you build on redhat-derived distributions, you'll have to manually
remove the mime dir every time after doing a make install.

M  +3    -0    linux/build-image.sh

http://commits.kde.org/krita/2b35122a513c062a28e302e86c6c5d18cdb3d594
Comment 16 Halla Rempt 2016-05-02 12:29:24 UTC
Git commit d9c68ec2f32e7db3564db1f269500ac0fa4bd57b by Boudewijn Rempt.
Committed on 02/05/2016 at 12:27.
Pushed by rempt into branch 'master'.

This should fix bug 361973 even for people who build Krita on
their own. It must be a bug somewhere in Qt, and a recent
regression, too. Just stopping to use QMimeDataBase doesn't
fix it, since it's some Qt-internal usage that breaks everything
in QFileDialog if there is a mime directory in the XDG_DATA_DIRS.

M  +0    -6    CMakeLists.txt
M  +0    -1    krita/data/CMakeLists.txt
D  +0    -9    krita/data/mime/CMakeLists.txt
D  +0    -36   krita/data/mime/krita.xml
D  +0    -7    krita/data/mime/x-gimp-brush-animated.xml
D  +0    -8    krita/data/mime/x-gimp-brush.xml
M  +0    -3    linux/build-image.sh
M  +0    -5    plugins/flake/vectorshape/CMakeLists.txt
D  +0    -13   plugins/flake/vectorshape/krita_svm.xml
M  +0    -5    plugins/impex/ora/CMakeLists.txt
D  +0    -18   plugins/impex/ora/krita_ora.xml

http://commits.kde.org/krita/d9c68ec2f32e7db3564db1f269500ac0fa4bd57b