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

Regression: QFileDialog::getOpenFileNames() freezes for longer time

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.2
    • None
    • Linux/X11

    Description

      Run the following example. When compiled with Qt 5.15 the dialog appears immediately. When compiled with Qt 6.2 (with sha: f218ef03f506c2080c9d109b4e5b26601d0d1dbf), the dialog appears after about 10 seconds.

      #include <QApplication>
      #include <QDebug>
      #include <QElapsedTimer>
      #include <QFileDialog>
      #include <QTemporaryDir>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QMetaObject::invokeMethod(qApp, [] {
              QElapsedTimer timer;
              timer.start();
              QTemporaryDir dir;
              QDir tempPath(dir.path());
              const QString dirPath = tempPath.absolutePath();
              const int count = 1000;
              int generatedCount = 0;
              for (int i = 0; i < count; ++i) {
                  QFile file(tempPath.filePath(QString("file_%1").arg(i)));
                  if (file.open(QIODevice::WriteOnly)) {
                      file.write("bla");
                      file.close();
                      ++generatedCount;
                  }
              }
              const int elapsedTime = timer.elapsed();
              qDebug() << "Generated" << generatedCount << "out of desired" << count
                       << "files inside temporary dir" << dirPath << "took" << elapsedTime << "ms.";
              QFileDialog::getOpenFileNames(nullptr, "Get Files", dirPath);
              QMetaObject::invokeMethod(qApp, &QCoreApplication::quit, Qt::QueuedConnection);
          }, Qt::QueuedConnection);
          return a.exec();
      }
      

      It looks like the more files is to be shown, the longer the freeze is.

      This happens with own build of Qt 6.2. It looks like I'm getting not a system file dialog, but Qt's one. When I build this example with released Qt 6.2.0 then I'm getting system dialog and it works fine.

      Discovered inside Creator 6 when built with Qt 6.2.

      Attachments

        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
            jkobus Jarek Kobus
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes