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

Linux: QQuickOverlay geometry is not finalized before Component.onCompleted

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.7.2, 6.8.0 Beta2
    • Quick: Controls 2
    • None
    • Ubuntu 22.04 in VMware Workstation Pro 16.2.4; Windows 10 22H2
    • Linux/Wayland, Linux/X11

    Description

      Test 1: QML
      Code

      import QtQuick
      import QtQuick.Controls.Basic
      
      Window {
          id: win
          width: 600
          height: 400
          visible: true
      
          Overlay.overlay {
              onWidthChanged: console.log("New overlay width:", Overlay.overlay.width)
              onHeightChanged: console.log("New overlay height:", Overlay.overlay.height)
          }
      
          Component.onCompleted: {
              console.log("At completion...")
              console.log("...the window is visible?", win.visible)
              console.log(`...the window size is ${win.width}x${win.height}`)
              console.log(`...the overlay size is ${Overlay.overlay.width}x${Overlay.overlay.height}`)
          }
      }
      

       

      Expected output (Windows)

      qml: New overlay width: 600
      qml: New overlay height: 400
      qml: At completion...
      qml: ...the window is visible? true
      qml: ...the window size is 600x400
      qml: ...the overlay size is 600x400
      

       

      Actual output (Linux)

      qml: At completion...
      qml: ...the window is visible? true
      qml: ...the window size is 600x400
      qml: ...the overlay size is 0x0
      qml: New overlay width: 600
      qml: New overlay height: 400
      

       

      Test 2: C++
      Code

      #include <QGuiApplication>
      #include <QQuickWindow>
      #include <QTimer>
      #include <private/qquickoverlay_p.h>
      
      using namespace Qt::StringLiterals;
      using namespace std::chrono_literals;
      
      QQuickWindow *window;
      QQuickOverlay *overlay;
      
      static void reportSizes()
      {
          qDebug().noquote() <<
                  u"Window: %1x%2 Visible?: %3 Exposed?: %4 Overlay: %5x%6"_s
                  .arg(window->width())
                  .arg(window->height())
                  .arg(window->isVisible())
                  .arg(window->isExposed())
                  .arg(overlay->width())
                  .arg(overlay->height());
      }
      
      int main(int argc, char *argv[])
      {
          QGuiApplication app(argc, argv);
      
          QQuickWindow w;
          w.setWidth(600);
          w.setHeight(400);
          w.show();
      
          window = &w;
          overlay = QQuickOverlay::overlay(window);
      
          reportSizes();
          QTimer::singleShot(0ms, &app, &reportSizes);
          QTimer::singleShot(10ms, &app, &reportSizes);
          QTimer::singleShot(100ms, &app, &reportSizes);
      
          return app.exec();
      }
      
      

       

      Expected output (Windows)

      Window: 600x400 Visible?: 1 Exposed?: 0 Overlay: 600x400
      Window: 600x400 Visible?: 1 Exposed?: 0 Overlay: 600x400
      Window: 600x400 Visible?: 1 Exposed?: 0 Overlay: 600x400
      Window: 600x400 Visible?: 1 Exposed?: 1 Overlay: 600x400
      

       

      Actual output (Linux)

      Window: 600x400 Visible?: 1 Exposed?: 0 Overlay: 0x0
      Window: 600x400 Visible?: 1 Exposed?: 0 Overlay: 0x0
      Window: 600x400 Visible?: 1 Exposed?: 0 Overlay: 600x400
      Window: 600x400 Visible?: 1 Exposed?: 1 Overlay: 600x400
      

       

      Notes

      • To get the exact output of Test 2 (C++) above, you might need to tweak the duration passed to QTimer::singleShot(), or run the application through the debugger to slow down its execution.
      • I'm not sure if this is a bug, or just a platform-dependent behaviour that we need to deal with. This makes me think of QTBUG-119225
      • This delay in geometry finalization caused the test failures at https://codereview.qt-project.org/c/qt/qtdeclarative/+/547039 (Patchset 5). The delay does not seem to be tied to QQuickWindow::isVisible() or QQuickWindow::isExposed(), so calling QTest::qWaitForWindowExposed() won't guarantee that the test passes.

      Attachments

        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
              skoh-qt Sze Howe Koh
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes