Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-137062

XDG_DATA_DIRS order is inverted for PNG icons

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5, 6.8, 6.9, 6.10
    • GUI: Look'n'Feel
    • None
    • Linux/Wayland, Linux/X11

    Description

      1. Unpack icons.tar.gz to the root
      2. Build the following code:
        g++ -o main main.cpp $(pkg-config --cflags --libs Qt6Widgets)
        #include <QtWidgets>
        
        int main(int argc, char **argv) {
        	QApplication app(argc, argv);
        	QWidget window;
        	const auto layout = new QHBoxLayout(&window);
        	const auto png = new QLabel;
        	png->setPixmap(QIcon::fromTheme("test-png").pixmap(256, 256));
        	layout->addWidget(png);
        	const auto svg = new QLabel;
        	svg->setPixmap(QIcon::fromTheme("test-svg").pixmap(256, 256));
        	layout->addWidget(svg);
        	window.show();
        	return app.exec();
        }
        

      Expected behavior: both labels display 2
      Actual behavior:

      I suspect the cause is https://github.com/qt/qtbase/blob/a3b24c2842cf48bf0d82d8d52ce2dc0edd441fc4/src/gui/image/qiconloader.cpp#L516-L531, it prepends PNG icons to the front of vector which inverts the order. It perhaps should use a separate vector instead and then concatenate the two.

      This is especially annoying in snap where XDG_DATA_DIRS contains folders Qt can access in the front and folders Qt can't access in the back, inverting the order leads to Qt using icon paths it can't access what leads to Qt being unable to render PNG icons at all: https://bugs.launchpad.net/snapd/+bug/2104626

      Attachments

        1. image-2025-05-21-15-03-29-142.png
          33 kB
          Ilya Fedin
        2. icons.tar.gz
          7 kB
          Ilya Fedin
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            ilya-fedin Ilya Fedin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes