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

QIcon::fromTheme() incorrectly handles fallback themes (hicolor) and names

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 5.5.0, 5.10.1, 5.11.0
    • GUI: Look'n'Feel
    • None

      The Icon Theme Specification describes a particular behavior for the lookup of icons and fallback handling:

      1. Look for exact icon name in current theme
      2. Look for exact icon name in current theme's parents, recursively
      3. Look for exact icon name in the "hicolor" fallback theme, which always must come last
      4. Repeat 1-3 using fallback icon names (i.e., remove dash-separated components from the right)

      Unfortunately, QIconLoader uses a different algorithm:

      1. Forcefully add "hicolor" as parent for every theme in the hierarchy
      2. Look for exact icon name in current theme
      3. Look for fallback icon name in current theme
      4. Repeat 2-3 for the parents of the current theme, which unfortunately due to 1 means that hicolor is searched next instead of last

      So, this has two effects:

      • No matter the inheritance chain defined in the index.theme files, hicolor is always looked into second, because QIconLoader wrongly adds it as a parent to every theme, instead of ensuring it is used as the very last resort as specified. Instead, Qt should follow the complete inheritance chain (look up all parents recursively), ensuring that hicolor is skipped until the end. To quote the specification, "implementations may add more default themes before "hicolor", but "hicolor" must be last".
      • Fallback icon names have priority over looking into the parents. That is, if we're looking for "network-connect", and the current theme has "network" while one of its parents has "network-connect", the former is returned rather than the latter. While this may even be desirable in certain situations, it should at the very least be configurable somehow, because in the general case it seems to make more sense to return a specific icon from an inherited theme over a more general icon from the current theme.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            iamsergio Sergio Martins
            sputnick Manuel Nickschas
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes