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

Creating button when QDialog is being destructed

    XMLWordPrintable

Details

    Description

      When QMessageBox/QDialog destructor is called the subsequent call of QMessageBoxPrivate::setVisible(false) is called andfollowing portion of code

      Q_Q(QMessageBox);
          if (q->testAttribute(Qt::WA_WState_ExplicitShowHide) && q->testAttribute(Qt::WA_WState_Hidden) != visible)
              return;
      
          // Last minute setup
          if (autoAddOkButton)
              q->addButton(QMessageBox::Ok);
          detectEscapeButton();
      
          if (canBeNativeDialog())
              setNativeDialogVisible(visible);
      
          // Update WA_DontShowOnScreen based on whether the native dialog was shown,
          // so that QDialog::setVisible(visible) below updates the QWidget state correctly,
          // but skips showing the non-native version.
          q->setAttribute(Qt::WA_DontShowOnScreen, nativeDialogInUse);
      

      is invoked even if visible false is passed.

      Which means that for exmaple here we invoke full initialization cicle for button

       if (autoAddOkButton)

      q->addButton(QMessageBox::Ok);

      PROPOSAL

      Modify  if (autoAddOkButton) to  if (autoAddOkButton && visible)

       

      Attachments

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

        Activity

          People

            axelspoerl Axel Spoerl
            mitia Dmytro Tristan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes