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

QFileDialog memory leak

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • 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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            crowww Wang Brazen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: