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

QFileDialog::getOpenFileName crashes when parent is deleted while dialog is open

    XMLWordPrintable

Details

    • 5
    • 81d55f772 (dev), ca3fa76a4 (6.8), 746c1b611 (6.7), 150b856f0 (tqtc/lts-6.5)
    • Foundation Sprint 104, Foundation Sprint 105, Foundation Sprint 106, Foundation Sprint 115

    Description

      Calling "QFileDialog::getOpenFileName" and then deleting the parent given to this function will crash Qt on Windows 10 64-bit.

      I suspect the reason is similar to: https://blogs.kde.org/2009/03/26/how-crash-almost-every-qtkde-application-and-how-fix-it-0

      Update
      In case it helps, this will easily reproduce the crash:

      int main(int argc, char **argv) {
        QApplication application{argc, argv};
      
        QMainWindow *main_window = new QMainWindow();
        main_window->show();
      
        QPushButton *button = new QPushButton("Press me");
        main_window->setCentralWidget(button);
      
        QObject::connect(button, &QPushButton::clicked, [main_window]() {
          QTimer::singleShot(2000, [main_window]() { delete main_window; });
      
          QFileDialog::getOpenFileName(main_window, "Close me fast or I will crash!");
        });
      
        application.exec();
      
        return 0;
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              tatiana.borisova Tatiana Borisova
              rggjan Jan Rüegg
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: