Bug 439790 - Exported Kate theme reports (incorrect) error message when the theme is imported.
Summary: Exported Kate theme reports (incorrect) error message when the theme is impor...
Status: CONFIRMED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-12 22:22 UTC by Peter C. Trenholme
Modified: 2024-09-13 19:43 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Dolphin showing the same error messages (419.32 KB, image/gif)
2021-07-14 10:41 UTC, Jan Paul Batrina
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter C. Trenholme 2021-07-12 22:22:39 UTC
SUMMARY
Exported kate theme reports (incorrect) error message wmen the theme is imported.

STEPS TO REPRODUCE
1. Start kate
2. Export the theme
3. Exit kate
4. Open a terminal window and start kate
5. Import the save theme file
6. See the (spurious) error messages about missing "=" symbols.

Note that JSON files do not, generally, use "=" delimiters. They most often use ":" delimiters, which are (correctly) used in the generated ".theme" file.
OBSERVED RESULT
See above

EXPECTED RESULT
No spurious error messages.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE: Ferora 34
(available in About System)
KDE Plasma Version: 5.22.2
KDE Frameworks Version: 5.83.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
From my terminal output . . .

qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 13495, resource id: 14790069, major code: 40 (TranslateCoords), minor code: 0
kf.config.core: "KConfigIni: In file /root/MyKateTheme.theme, line 1: " Invalid entry (missing '=')
kf.config.core: "KConfigIni: In file /root/MyKateTheme.theme, line 2: " Invalid entry (missing '=')
kf.config.core: "KConfigIni: In file /root/MyKateTheme.theme, line 3: " Invalid entry (missing '=')
kf.config.core: "KConfigIni: In file /root/MyKateTheme.theme, line 4: " Invalid entry (missing '=')
kf.config.core: "KConfigIni: In file /root/MyKateTheme.theme, line 5: " Invalid entry (missing '=')
kf.config.core: "KConfigIni: In file /root/MyKateTheme.theme, line 6: " Invalid entry (missing '=')
kf.config.core: "KConfigIni: In file /root/MyKateTheme.theme, line 7: " Invalid entry (missing '=')
kf.config.core: "KConfigIni: In file /root/MyKateTheme.theme, line 8: " Invalid entry (missing '=')
kf.config.core: "KConfigIni: In file /root/MyKateTheme.theme, line 9: " Invalid entry (missing '=')
kf.config.core: "KConfigIni: In file /root/MyKateTheme.theme, line 10: " Invalid entry (missing '=')

Oh, you may note that I was running as "root."

I have another problem, unrelated to this minor one, and not (I think) a KDE one: PAM has decided that my user names (except "root") are all invalid because 
(as far as I can tell) I named my user accounts with the user's first names, with correct -- mixed case -- spelling. The accounts are still there -- I can su into them from root-- but not log in from console. (Sorry - just venting.)
Comment 1 Jan Paul Batrina 2021-07-14 10:41:09 UTC
Created attachment 140046 [details]
Dolphin showing the same error messages

Confirmed with kate from git master (even with non-root users)

The error is technically not from kate, but from dolphin or the file selection dialog. For example, if we directly put the theme file path in https://invent.kde.org/frameworks/ktexteditor/-/blob/master/src/syntax/katethemeconfig.cpp#L1091 instead of the QFileDialog::getOpenFileName call, the KConfigIni error messages do not appear.

Additionally, the errors only appear when hovering (mouse-over) on kate theme files, or when such a file was previously/recently selected using the file dialog in kate.

The same errors appear for other file dialogs in kate (e.g. File > Open and File > Save as) and also when using Dolphin directly, so it's possible that it is a dolphin bug.
Comment 2 Jan Paul Batrina 2021-07-16 18:23:37 UTC
After a bit more poking, I have confirmed that the errors are coming from dolphin/KIO, but the bug is still for kate/ktexteditor. Specifically, the errors when the mouse hovers over a kate theme file are coming from the KDesktopFile constructor in this line https://invent.kde.org/frameworks/kio/-/blob/master/src/core/kfileitem.cpp#L895. I haven't located exactly where the errors for the recent files come from, but I expect they are of similar nature since they also appear in dolphin.

e.g. xdg-mime query filetype export.theme returns application/x-theme, which apparently inherits application/x-desktop. Thus it is treated by KIO as a desktop file which is in INI format but the kate theme files are in JSON.

The .theme file extension is also used by GTK themes (e.g. vhttps://github.com/adapta-project/adapta-gtk-theme/blob/master/gtk/index.theme), which are indeed in INI format, and this probably is the reason why an INI is expected. FWIW dock also uses an INI .theme file for themes (e.g. https://github.com/nana-4/materia-theme/blob/master/src/plank/dock.theme), but that might just be a coincidence.

I think the simplest fix (not necessarily the easiest) is to use a different file extension for kate color themes (e.g. .ktetheme, .kshltheme). This would require (minor) changes to KTextEditor and KSyntaxHighlighting, but also might require special (transitional) handling for existing installations and third party themes.
Comment 3 Christoph Cullmann 2021-10-03 19:55:57 UTC
I assume you are right, the .theme ending was not the best idea.

I would even rather settle just for .json for the files.
Beside a bit compat code, I see no large issue with renaming them.
Comment 4 Christoph Cullmann 2024-09-13 19:43:29 UTC
Hmm, on the other side, it is no good idea that we spit out errors, .theme is perhaps an ini for icon themes, but that ending can be used by anything else, too.