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

Deadlock in QShGetFileInfoThread (result of using QFileIconProvider)

    XMLWordPrintable

Details

    • Task
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.10.1
    • Widgets: Itemviews
    • None
    • Windows 10, Qt 5.10.1 64-bit, both Debug and Release

    • Windows

    Description

      When using QFileIconProvider to get the file icon's pixmap in a multithreaded environment (e.g. for custom implementation of QML's QQuickImageProvider) the program hangs.

      I managed to trace the problem to QShGetFileInfoThread (which always appears in the call-stack).

      Minimal repro - 100% reproducible for me:

      #include <QDebug>
      #include <QtConcurrent/QtConcurrentMap>
      #include <QApplication>
      #include <QDir>
      #include <QFileIconProvider>
      
      int main(int argc, char *argv[])
      {
        QApplication a(argc, argv);
      
        QFileIconProvider provider;
      
        auto files = QDir("C:/Windows").entryList(QDir::Files);
      
        qDebug() << "starting for" << files.size() << "items";
      
        std::atomic<int> count{0};
      
        QtConcurrent::map(files, [&](auto file){
          provider.icon(QFileInfo(file)).pixmap(60, 60);  // << this line causes deadlock in QShGetFileInfoThread 
          qDebug() << file << ++count << files.size();
        });
      
        a.exec();
      }
      
      

      Example output:

      starting for 32 items
      
      "diagerr.xml" 1 32
      
      "comsetup.log" 2 32
      
      "bootstat.dat" 3 32
      
      "bfsvc.exe" 4 32
      

      Then the application hangs forever (above, the output should count to 32 and stop).

      Attachments

        1. thread-5.png
          thread-5.png
          40 kB
        2. thread-9.png
          thread-9.png
          12 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            sthlm58 Michal Kucharski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes