Bug 405475 - Can't open .kra file
Summary: Can't open .kra file
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Halla Rempt
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-14 16:57 UTC by Konstantin Dmitriev
Modified: 2019-04-04 09:09 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Dmitriev 2019-03-14 16:57:51 UTC
SUMMARY
Cannot open .kra file (attached) in latest development version.
Git commit id: 3805574 (built on March 13, appimage from https://binary-factory.kde.org/job/Krita_Nightly_Appimage_Build/406/).

File opens fine in Krita 4.1.7.

STEPS TO REPRODUCE
1. Open attached file in Krita
2. Error message displayed.
3. After that file opens, but all layers are empty.

OBSERVED RESULT
File opens, but all layers are empty.

EXPECTED RESULT
File should be open normally.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Linux Mint 19 Mate edition


ADDITIONAL INFORMATION
Comment 1 Halla Rempt 2019-03-14 16:59:38 UTC
If the file is too large to attach, please use a dropbox or google drive link, or something like that.
Comment 2 Konstantin Dmitriev 2019-03-14 17:16:02 UTC
Got it! Here is the affected file ^__^ - https://download.morevnaproject.org/public/118-5-storyboard-54-7-bug.kra
Comment 3 Halla Rempt 2019-03-14 20:39:35 UTC
That's curious... Krita ought to save layer names as UTF-8, but what's in this file is definitely not UTF-8, when I check when unzipping it. Weirder still, we can still show the layernames in what I assume is the correct representation in the dev version.
Comment 4 Halla Rempt 2019-03-15 07:51:29 UTC
What is the locale of the system the file was saved on?
Comment 5 Halla Rempt 2019-03-15 08:23:44 UTC
If I open with 4.1.7 on a system with LANG=en_US.UTF-8 and save it, the file can be read with the latest master. Somehow, 4.1.7 saves the image name (which is used in the path to the layers) with the local encoding instead of UTF-8.
Comment 6 Halla Rempt 2019-03-15 09:10:06 UTC
Git commit f4a4194125d4b152aabc5662bf09191df998c638 by Boudewijn Rempt.
Committed on 15/03/2019 at 09:09.
Pushed by rempt into branch 'master'.

Fix problems when loading Krita 4.1 files saved in non-utf-8 locales

Krita 4.1 has a bug where when the locale is not utf-8, the entries
in the zip file entrylist are in the local locale, not utf-8. The
image name is encoded in utf-8 in the maindoc.xml file, but the
layers are, because of ancient history when more than one image
could be stored in a kra file, in a subfolder with the image name.

So, if the image name in utf-8 is different from the image name
in the directory, quazip gets confused because it actually handles
encoding correctly.

Ark also cannot load kra files that are borked in this with.

This hack substitutes the encoded name for the utf-8 name in the
quazip store implementation, and now the files can load again.

M  +13   -6    libs/store/KoQuaZipStore.cpp
M  +7    -0    libs/store/KoStore.cpp
M  +3    -0    libs/store/KoStore.h
M  +3    -0    libs/store/KoStore_p.h
M  +12   -0    plugins/impex/kra/kra_converter.cpp
M  +5    -1    plugins/impex/libkra/kis_kra_loader.cpp
M  +6    -0    plugins/impex/libkra/kis_kra_loader.h

https://commits.kde.org/krita/f4a4194125d4b152aabc5662bf09191df998c638
Comment 7 Konstantin Dmitriev 2019-03-15 09:13:40 UTC
Thank you for the fix!

Just some additional info:
The file was created in Krita 4.1.7 on Linux. Then edited in Krita (probably 4.1.7) on Windows. After that it faile to open on Linux with dev version.

Opening file in Krita 4.1.7 on Linux AND re-saving it (even without any LANG tweaks) fixes the problem. ^__^
Comment 8 Halla Rempt 2019-03-15 09:25:55 UTC
Then I strongly suppose that the Windows system was set to a non-utf-8 locale :-)
Comment 9 Halla Rempt 2019-04-04 09:09:43 UTC
Git commit 3a4bfb2858415cf6fdec2a7d8e6cef97c2f218a0 by Boudewijn Rempt.
Committed on 04/04/2019 at 09:09.
Pushed by rempt into branch 'master'.

Fix loading kra files with / in the image name
Related: bug 405942

M  +1    -4    libs/store/KoQuaZipStore.cpp
M  +5    -0    libs/store/KoStore.cpp
M  +7    -1    libs/store/KoStore.h
M  +3    -3    plugins/impex/kra/kra_converter.cpp

https://commits.kde.org/krita/3a4bfb2858415cf6fdec2a7d8e6cef97c2f218a0