Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kiconthemes-5.80.0 ruins LXQt's colorizing of SVG icons #246

Closed
tsujan opened this issue Mar 16, 2021 · 17 comments
Closed

kiconthemes-5.80.0 ruins LXQt's colorizing of SVG icons #246

tsujan opened this issue Mar 16, 2021 · 17 comments

Comments

@tsujan
Copy link
Member

tsujan commented Mar 16, 2021

I know that this may sound impossible but I'm 100% sure about it: kiconthemes-5.80.0 came here with a KDE upgrade and made all my icons disappear after a logout and login (or reboot). It took me more than an hour to find out that it was kiconthemes and not one ot the other 76 KDE packages (in Arch) that caused the problem.

The problem happens with Breeze or any SVG icon set that has stylesheet. If I uncheck "Colorize icons..." in LXQt Appearance Configuration → Icon Theme, the icons will be shown; if I check it again, the icons will disappear. It was checked before. Downgrading kiconthemes to 5.79.0 removes the issue.

For now, I don't have the slightest idea how a KDE package can affect our icon handling but it's very annoying!

@tsujan
Copy link
Member Author

tsujan commented Mar 16, 2021

The intruding commit is KDE/kiconthemes@5666c0c. I got rid of the problem by reversing it. I haven't found another way yet; particularly, registering XdgIconLoaderEngine for svg had no effect.

The issue isn't limited to colorizing: some icon paths aren't seen either. For example, the start menu icons of some panel themes become blank.

An intrusion by another icon engine is bad. Something is missing from our code?

@tsujan
Copy link
Member Author

tsujan commented Mar 16, 2021

OK, registering XdgIconLoaderEngine for svg was a baseless idea -- I'd forgotten the code of xdgiconloader.cppScalableFollowsColorEntry::pixmap().

With the above-mentioned commit, kiconthemes practically hides qtsvg from us by stealing its key, namely "svg". Therefore, even if we use QSvgRenderer directly (with a self-made cache) or resort to the old method (#144), we'll still be at the mercy of kiconthemes without colorizing and will suffer from its bugs (I mentioned one above).

It seems to me that the only ways out of this situation are (1) not installing kiconthemes -- which means not installing KDE alongside LXQt (not acceptable for many); or (2) reversing the bad commit; or (3) handling SVG completely as kiconthemes does (cumbersome).

@Chiitoo
Copy link

Chiitoo commented Mar 16, 2021

Interesting. This commit broke things in a different way for me, where Falkon and some other applications didn't even start (fixed in 65ee2fac [1]).

Unfortunately, I use the Oxygen icon theme which seems unaffected. Could have reported this, too, while reporting the other issue...

  1. https://invent.kde.org/frameworks/kiconthemes/-/merge_requests/22

@stefonarch
Copy link
Member

@yan12125 mentioned this in IRC https://bugs.archlinux.org/task/69988

@tsujan
Copy link
Member Author

tsujan commented Mar 16, 2021

@Chiitoo, @stefonarch, thanks!

Happy to know that @yan12125 had seen the problem before me -- Arch updates came to Manjaro Testing (my distro) only last night.

The solution No. 3 is always possible (I'll try it as soon as I find some time) but the above-mentioned commit isn't acceptable: no engine should introduce itself by using the key of another one, especially when the latter is so important.

@yan12125
Copy link
Member

Thanks for creating this issue. I was going to open one :)

I mentioned the problematic commit in https://bugs.kde.org/show_bug.cgi?id=434451. Let's see what KDE devs think. The best option is fixing the issue in KDE. If no KDE devs respond in a few days, I will ask if KDE maintainers at Arch want to revert that commit like this PKGBUILD.

@tsujan
Copy link
Member Author

tsujan commented Mar 16, 2021

I mentioned the problematic commit in...

Thanks a lot!

I hope KDE will reverse it but using of QSvgRenderer for all SVG icons in our icon engine should prevent such nasty issues. With an appropriate cache, I don't think there would be an overload but I should first test it. Our current code works fine but it isn't elegant because it depends on how things are done in qtsvg's code.

@stefonarch
Copy link
Member

I blocked update of kiconthemes in /etc/pacman.conf, no issue.

@tsujan
Copy link
Member Author

tsujan commented Mar 16, 2021

I tried QSvgRenderer with QPixmapCache and, as far as my quick tests showed, it worked fine in spite of the above-mentioned commit.

However, apparently, kiconthemes-5.80.0 is still an issue with icons of some stylesheets (like those of lxqt-panel). The problems that it creates can't be completely avoided. That commit should be reversed.

@yan12125
Copy link
Member

KDE devs are discussing about reverting it: https://invent.kde.org/frameworks/kiconthemes/-/merge_requests/25

Somehow I failed to create an account for logging into KDE's GitLab :/

@yan12125
Copy link
Member

yan12125 commented Mar 18, 2021

Merge request 25 is closed in favor of https://invent.kde.org/frameworks/kiconthemes/-/merge_requests/26. Looks like KDE devs are willing to fix bugs in kiconthemes while they also want to keep kiconthemes as the svg handler...

@tsujan Do you have an account on KDE's but tracker? I'd like explain why things are broken in LXQt, but I'm not familiar with libqtxdg or lxqt-qtplugin enough to write a good comment. If you don't, I can also forward explanations.

PS: with the new kiconthemes patch (MR 26), the issue in LXQt still persists.

@tsujan
Copy link
Member Author

tsujan commented Mar 18, 2021

Looks like KDE devs are willing to fix bugs in kiconthemes while they also want to keep kiconthemes as the svg handler...

Very bad decision! I fixed the colorizing here by using QSvgRenderer but the non-colorized mode will be ignored by kiconthemes. I might be able to fix that too but I think SVG icons will still have problems in Qt stylesheets.

@tsujan Do you have an account on KDE's but tracker?

I do but I'm too angry now. Maybe later. For now, I prefer to focus on my workaround for LXQt not to be at the mercy of such decisions in future.

tsujan added a commit that referenced this issue Mar 18, 2021
`QSvgRenderer` is used with a cache for both ordinary and colorized SVG icons. In this way, LXQt's icon handling cannot be broken by intruding icon engines, which register themselves for "svg" (see #246). Moreover, it does not depend on a specific code structure of `qtsvg` or any other icon engine.
@tsujan
Copy link
Member Author

tsujan commented Mar 18, 2021

This is my proposal: #247

It may seem complex in the form of a patch but its logic is as simple as this: use QSvgRenderer to draw SVG icons, whether they're colorized or not.

It passed my tests after I re-installed the problematic kiconthemes V5.80.0.

As for stylesheets, I can see only the lack of start menu icon in one LXQt theme (Kvantum). I can't explain it but it can be easily fixed by a simple change.

Of course, more tests are needed. Also, an LXQt dev may find and fix a problem in the PR; it definitely needs a review.

@tsujan
Copy link
Member Author

tsujan commented Mar 19, 2021

OK, I can't see any problem in practice but it should be tested more.

I think the most important thing was preventing plugins like kiconthemes from ruining LXQt's handling of SVG icon themes. That's done by the PR.

The remaining issue is that, if kiconthemes is present, it'll still be active — with its bugs and "features" — wherever an SVG file is direcctly used as an icon. I don't think we can do anything about it without making the same mistake that KDE made. IMO, the possibility of abusing JSON files in this way is an issue in Qt.

A word about why I got angry at first (→ #246 (comment)):

Suppose that I'd made the Oxygen widget style disappear by adding it to Kvantum's JSON file. That's quite possible. If I did so, you'd choose "Oxygen" in LXQt Appearance Configuration but you'd see only Kvantum! Would you congratulate me on my decision?

@palinek
Copy link
Contributor

palinek commented Mar 19, 2021

IMO, the possibility of abusing JSON files in this way is an issue in Qt.

Heh...isn't this even a vulnerability?
With this, if you're able to fool the user to install your (other way valid) app (which will silently steel the svg rendering), then you can attack the victim with perfectly renderable .svg which includes malicious code/directions for your compromised "render engine".

@tsujan
Copy link
Member Author

tsujan commented Mar 19, 2021

isn't this even a vulnerability?

Yes, it can be seen as a vulnerability. You provided a good example.

I meant the relation of "power" and responsibility. In my example, the "power" is k < o; in the case of kiconthemes, it's K < l (KIconEnginePlugin.so → libqsvgicon.so).

tsujan added a commit that referenced this issue Mar 24, 2021
* Use QSvgRenderer for SVG icons

`QSvgRenderer` is used with a cache for both ordinary and colorized SVG icons. In this way, LXQt's icon handling cannot be broken by intruding icon engines, which register themselves for "svg" (see #246). Moreover, it does not depend on a specific code structure of `qtsvg` or any other icon engine.

* Just removed a redundant computation

* Used the same key structure for SVG cache
@tsujan
Copy link
Member Author

tsujan commented Mar 24, 2021

I think this can be closed now.

If a user opens an issue about, for example, the wrong size of flags in Panel's keyboard indicator, he/she could be asked to open an issue against kiconthemes. I'll try to patch every new version of kiconthemes here for comparison.

@tsujan tsujan closed this as completed Mar 24, 2021
kegechen added a commit to kegechen/libqtxdg that referenced this issue Dec 19, 2023
From: lxqt/libqtxdg#247
Use QImageReader instead of QSvgRender for XdgIconLoader
QSvgRender itself only support SVG 1.2 Tiny for rendering so SVGs
that more complex might not able to rendered properly. Thus, some
DE like KDE and DDE provides their own Qt icon engine and registered
them as for SVG icons, and seems that causes libqtxdg have issues, so
lxqt/libqtxdg/pull/246 was there.

But user or DE might still want to install or provide Qt image formats
plugins for better SVG files/icons rendering, using QSvgRender will
stop the Qt image formats plugin from being used.

Using QImageReader will still allow us avoiding the usage of Qt icon
engines, but kepts the ability to make Qt image formats plugin to
work properly.

This patch originally provided by @zccrs

Issue: linuxdeepin/developer-center#6480
deepin-ci-robot pushed a commit to deepin-community/libqtxdg that referenced this issue Dec 19, 2023
From: lxqt/libqtxdg#247
Use QImageReader instead of QSvgRender for XdgIconLoader
QSvgRender itself only support SVG 1.2 Tiny for rendering so SVGs
that more complex might not able to rendered properly. Thus, some
DE like KDE and DDE provides their own Qt icon engine and registered
them as for SVG icons, and seems that causes libqtxdg have issues, so
lxqt/libqtxdg/pull/246 was there.

But user or DE might still want to install or provide Qt image formats
plugins for better SVG files/icons rendering, using QSvgRender will
stop the Qt image formats plugin from being used.

Using QImageReader will still allow us avoiding the usage of Qt icon
engines, but kepts the ability to make Qt image formats plugin to
work properly.

This patch originally provided by @zccrs

Issue: linuxdeepin/developer-center#6480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants