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

[REG 5.5->5.6]: ASSERT in kernel\qwindow.cpp, line 396 triggered when reshowing a previously hidden QDialog with a QWidget if QWidget::winId() has been called

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.6.0 RC
    • 5.6.0 Beta
    • None
    • Reproduced with 32 and 64 bit builds on Windows 8.1 and 10, Breakage on XCB
    • cb6d4d1f16215694547514a6342e47854534223e (qtbase/5.6.0, 5.2.2016)

    Description

      To reproduce:
      1. Run the sample provided
      2. Click button
      3. Close dialog
      4. Click button again
      5a. Windows: Watch how the assert halt program execution...
      5b) Linux: 2nd toplevel temporarily flashes and is then reparented, shown with offset

      Windows: WIn32 API CreateWindowEx failed ()Error messages output from the test applications:

      WindowCreationData::create: CreateWindowEx failed (Cannot create a top-level child window.)
      ASSERT: "platformWindow" in file kernel\qwindow.cpp, line 396
      
      [The ViewWidget is recreated with parentHandle=0x0 and WS_CHILD]
      

      Code sample:

      #include <QMainWindow>
      #include <QDialog>
      #include <QPushButton>
      #include <QHBoxLayout>
      #include <QApplication>
      
      // ViewWidget
      class ViewWidget : public QWidget
      {
      public:
          ViewWidget(QWidget *parent = nullptr) : QWidget(parent)
          {
              winId(); // grab the native window handle to pass to external lib responsible for painting the view...
          }
      };
      
      // ViewDialog
      class ViewDialog : public QDialog
      {
      public:
          ViewDialog(QWidget *parent = nullptr) : QDialog(parent)
          {
              setWindowTitle(tr("View Dialog"));
              resize(160, 90);
      
              ViewWidget* view = new ViewWidget;
      
              QHBoxLayout* layout = new QHBoxLayout;
              layout->addWidget(view);
      
              setLayout(layout);
          }
      };
      
      // MainWindow
      class MainWindow : public QMainWindow
      {
          //Q_OBJECT
      
      public:
          MainWindow(QWidget *parent = nullptr) : QMainWindow(parent)
          {
              setWindowTitle(tr("Qt 5.6.0 beta bug Test"));
              resize(240, 120);
      
              QPushButton* button = new QPushButton("Click me!", this);
              connect(button, &QPushButton::clicked, this, &MainWindow::openDialog);
              setCentralWidget(button);
          }
      
          ~MainWindow() {}
      
      public slots:
          void openDialog()
          {
              static ViewDialog* dlg = nullptr;
      
              if (!dlg) dlg = new ViewDialog;
      
              dlg->show();
          }
      };
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          MainWindow main;
          main.show();
      
          return app.exec();
      }
      

      Attachments

        1. qtbug50854_closeeventpatch_reverted_log.txt
          4 kB
        2. qtbug50854_diag.diff
          0.6 kB
        3. qtbug50854_log.txt
          3 kB
        4. qtbug50854_stack.txt
          16 kB
        5. qtbug50854_widgets_diag.diff
          3 kB
        6. qtbug50854_win_qpa_log.txt
          18 kB
        7. qtbug50854.zip
          1 kB
        8. QTBUG-50854.zip
          1 kB

        Issue Links

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

          Activity

            People

              sorvig Morten Sørvig
              mikag Mikael Ågerud
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes