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

Consistent QWindow close event behavior

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P2: Important
    • None
    • None
    • GUI: Window management
    • None

    Description

      Closing a top-level QWindow should have consistent behavior regardless of API used or QWindow subclass in use.

      Desired behavior includes:

      • deleting the platform window
      • application last-window-closed logic

      Close APIs include:

      • QWindow::close()
      • QWindowSystemInterface::handleCloseEvent()
      • QWidget::close() (QWidgetWindow)
      • QtQuick.window.close() (QQuickWindow)

      Requirements:

      • Run all close logic at the various levels
      • Run close logic in the correct order.
      • Deduplicate logic as far as possible.

      Previous Work

      Some work has been done already for 5.6 and QTBUG-43344. This was partially reverted since it caused the regression described in QTBUG-50854.

      Implementation

      Control Flow
      1) All close API, for top-level QWindows, redirect control to QWindow::close() or QWindowSystemInterface::handleCloseEvent(). QWindow::close() calls handleCloseEvent().
      2) The QWindow subclass handles the CloseEvent. It runs subclass-specific close logic, and then calls QWindow::event() to pass the event to the QWindow base implementation.
      3) QWindow runs common close logic:

      • delete the platform window
      • application last-window-closed behavior (but this is currently duplicated in QWidgetWindow)
      TODO: who hide()s the window?
      quit-on-close

      Both QWidget and QWindow have quit-on-close logic. The one difference is that the QWidget version checks WA_QuitOnClose (widgets without that flag won't keep the app alive) while the QWindow version checks QGuiApplication::quitOnLastWindowClosed().

      Keeping (and running) both code paths make sense, to catch usages of both WA_QuitOnClose and QGuiApplication::quitOnLastWindowClosed(). This is not the current behavior: instead, QWindow will only run quit-on-close logic for windows that it itself hides (and not for windows that QWidget hides).

      Pending Changes

      https://codereview.qt-project.org/158701 (Unify window close behavior)

      Attachments

        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
              sorvig Morten Sørvig
              Veli-Pekka Heinonen Veli-Pekka Heinonen
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes