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

QFileDialog memory leak

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P1: Critical
    • None
    • 5.15
    • Widgets: Main Window
    • None
    • Windows

    Description

      QFileDialog cause memory leak when invoke QFileDialog::open
      Run the demo below, after a few times,QFileDialog dont work anymore

      #include <QApplication>
      
      #include <QFileDialog>
      #include <QTimer>
      
      void Test() {
        QWidget* w = new QWidget();
        w->show();
        QFileDialog* dialog = new QFileDialog(w);
        dialog->open(nullptr, nullptr);
      
        QTimer::singleShot(1000, w, [=]() {
          dialog->close();
          dialog->deleteLater();
          w->close();
          w->deleteLater();
          });
      }
      
      int main(int argc, char* argv[]) {
        SetCurrentProcessExplicitAppUserModelID(L"yes");
      
        QApplication a(argc, argv);
        a.setQuitOnLastWindowClosed(false);
        QTimer* loop_timer = new QTimer();
        loop_timer->setInterval(2000);
        loop_timer->setSingleShot(false);
        loop_timer->start();
        QObject::connect(loop_timer, &QTimer::timeout, loop_timer, [=]() {
          Test();
          });
      
        return a.exec();
      } 
      

      Attachments

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

        Activity

          People

            axelspoerl Axel Spoerl
            crowww Wang Brazen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes