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

Dialog's accepted() signal emitted before closed() when using non-zero-duration transitions

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 6.0, 6.1.0 RC
    • 5.15
    • Quick: Controls 2
    • None
    • 0d3b8f832aad04c255dac64588b2693f2119cc0c (qt/qtquickcontrols2/dev)

    Description

      https://doc.qt.io/qt-5/qml-qtquick-controls2-dialog.html#accept-method says:

      Closes the dialog and emits the accepted() signal.

      When running this code

      import QtQuick 2.12
      import QtQuick.Controls 2.12
      
      ApplicationWindow {
          width: 400
          height: 400
          visible: true
      
          Dialog {
              standardButtons: Dialog.Ok | Dialog.Cancel
              visible: true
              onAccepted: print("accepted")
              onClosed: print("closed")
          }
      }
      

      with the Material style (which has transitions for Dialog), the output is:

      qml: accepted
      qml: closed
      

      When run with the Default style (which has no transitions for Dialog), the output is:

      qml: closed
      qml: accepted
      

      Besides contradicting the documentation, the concrete problem with this is that it breaks code like this:

          onAccepted: project.modifyAnimation(animationIndex) // oops, animationIndex is -1
      
          onClosed: {
              animationIndex = -1
              animation = null
              acceptOnNextModify = false
          }
      

      This worked in my application (which uses the Material style) but failed in my tests, where I use the Default style to speed things up.

      I think we should fix this by changing the behaviour, and always emit accepted (and rejected) before closed, since they are emitted synchronously.

      Attachments

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

        Activity

          People

            mitch_curtis Mitch Curtis
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes