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

QFileSystemModel should have an option to disable icon loading; crashes if the icon provider is null

    XMLWordPrintable

Details

    • 2a8b27bf6 (dev), 9316d0b64 (dev), 1753af384 (6.7), 481d4fcc8 (6.6)

    Description

      I was testing the new Qt Quick TreeView; the manual test from https://codereview.qt-project.org/c/qt/qtdeclarative/+/384949 uses QFileSystemModel and TreeView to make a trivial file tree explorer. I noticed that if I try to open /tmp it takes quite some time (half a minute or so); this is on a very fast system with SSD RAID storage, but /tmp is tmpfs of course (RAM-based) so there's no excuse for it not to be instantaneous. ls is instantaneous. But strace reveals that QFileSystemModel is searching all the icon directories like mad for an icon for each file in my /tmp dir. And actually Qt is the reason there are so many files too: stuff like qquicktextedit-cd241c.ii qfilesystemmodel_p-73d971.ii and a couple thousand more, all zero-size files. But it doesn't matter; there are a lot of directories I could look at that have thousands of files in them.

      Not every use of QFileSystemModel needs icons. We have an option DontUseCustomDirectoryIcons, but how about DontUseIcons, so that the icon role is simply not populated at all?

      I tried setIconProvider(nullptr); that makes it crash, which could be considered a bug. So I tried adding null pointer checks to make it stop crashing; then I can explore only the top-level directories, but nothing inside them. Maybe it's because iconProvider->type() is the function that figures out whether each entry is a file or a directory, so if there's no icon provider, you can't even fully walk the tree. If so, that's not a great design, since QFileInfo already knows that much.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-99178
          # Subject Branch Project Status CR V

          Activity

            People

              ahmad.samir Ahmad Samir
              srutledg Shawn Rutledge
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: