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

Qt application stays on foreground after a call to QDesktopServices::openUrl

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.12.0 Beta 2
    • 5.6.3
    • GUI: Window management
    • None
    • Windows 10 Pro (multi-screen)
    • Windows
    • bde6a049494f40cd71004d6926899f115af0c3e6 (qt/qtbase/5.12)

    Description

      QDesktopServices::openUrl may launch an external application that will trigger our application to be deactivated, in that case, Qt attempts to close any active popup widget (see src\qtbase\src\widgets\kernel\qapplication.cpp line 3128).
      Unfortunaly this will make our application to be reactivated and its window to be set into foreground again as indicated by the following backtrace:

      qwindowsd.dll!QWindowsWindow::requestActivateWindow() Line 2012
      Qt5Guid.dll!QWindow::requestActivate() Line 986
      Qt5Widgetsd.dll!QWidgetPrivate::setFocus_sys() Line 6593
      Qt5Widgetsd.dll!QApplicationPrivate::setFocusWidget(QWidget * focus, Qt::FocusReason reason) Line 1848
      Qt5Widgetsd.dll!QWidget::setFocus(Qt::FocusReason reason) Line 6528
      Qt5Widgetsd.dll!QApplicationPrivate::closePopup(QWidget * popup) Line 3887
      Qt5Widgetsd.dll!QWidgetPrivate::hide_helper() Line 8019
      Qt5Widgetsd.dll!QWidget::setVisible(bool visible) Line 8225
      Qt5Widgetsd.dll!QWidget::hide() Line 7995
      Qt5Widgetsd.dll!QWidgetPrivate::close_helper(QWidgetPrivate::CloseMode mode) Line 8354
      Qt5Widgetsd.dll!QWidget::close() Line 8413
      Qt5Widgetsd.dll!closeAllPopups() Line 3007

      This may occur when the QDesktopServices::openUrl is triggered from a QMenu action shown on a popup (QWidget with Qt::Popup flag).
      See attachment to reproduce.

      A workaround is to call:

      if (QApplication::activePopupWidget()) QApplication::activePopupWidget()->close();

      before QDesktopServices::openUrl.

       

      Attachments

        1. qtbug70810.zip
          2 kB
        2. qtbug70810_diag.diff
          2 kB
        3. popup_test.zip
          2 kB

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              e.jorge Jorge Emmanuel
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes