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

QIcon::fromTheme very slow for repeated failed lookups

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • 6.5.1, 6.6.0
    • 6.2.4, 6.3.2, 6.4.3, 6.5.0 RC
    • GUI: Look'n'Feel
    • None
    • Linux/X11
    • 74a4f9cb0 (dev), 8a805c1fd (6.5)

    Description

      I noticed significantly slower startup with my application built against Qt 6 compared to Qt 5. After some profiling, the increased startup time turned out to be related to loading of theme icons through QIcon::fromTheme. Previously (as of Qt 5), when an icon could not be found, it would anyway cache the result (a null icon) and subsequent calls to QIcon::fromTheme would return instantly. Since Qt 6, the function no longer caches failed icon lookups so each QIcon::fromTheme call again searches for the icon in all directories.

      This, combined with the fact that the default icon theme "Adwaita" does not provide any of the icons searched for by my application (since it only provides "symbolic" version), causes the icon lookups to take about half a second more during application startup.

      The caching of failed lookups was removed in https://codereview.qt-project.org/c/qt/qtbase/+/343396 and https://codereview.qt-project.org/c/qt/qtbase/+/419489. I personally think there has to be a better workaround for this, but I'm not sure about the best approach.

      I've attached a small example project to demonstrate the issue. Note that it will be quite fast when the theme does have the icons, but very slow when it doesn't, like for GNOME's Adwaita theme.

      Attachments

        1. image-2023-03-23-22-14-42-054.png
          image-2023-03-23-22-14-42-054.png
          170 kB
        2. main.cpp
          3 kB
        3. theme-icons.qbs
          0.0 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            axelspoerl Axel Spoerl
            bjorn Thorbjørn Lindeijer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes