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

Setting layout margin to zero causes content not to be rendered

    XMLWordPrintable

Details

    • 859cca02

    Description

      Testing was done on qt-s60-public/4.6, commit 383c336b.

      Running the attached test app, SimpleTest, should result in the entire screen being painted red.

      Uncommenting the SET_OUTERLAYOUT_CONTENTS_MARGINS macro in widgets.h causes the content margins of the main layout to be set to zero. When the app is now run, nothing is drawn on the screen.

      The sequence of events which cause this bug are as follows:

      1. QWidget::showFullScreen() is called on the top-level widget. This calls the following:

          QWidget::setWindowState
              QWidget::adjustSize
                  QWidgetPrivate::adjustedSize
      

      2. Because the widget has no sizeHint, and its margins are all zero, adjustedSize() returns QSize(0,0)

      3. QWidget::adjustSize() then passes this size to QWidget::resize(), which calls QWidget::setGeometry_sys()

      4. In the following snippet from QWidget::setGeometry_sys(), w == 0 and h == 0

          if (q->isWindow()) {
              if (w == 0 || h == 0) {
                  q->setAttribute(Qt::WA_OutsideWSRange, true);
                  if (q->isVisible() && q->testAttribute(Qt::WA_Mapped))
                      hide_sys();
                  data.crect = QRect(x, y, w, h);
                  data.window_state &= ~Qt::WindowFullScreen;
              } else if (q->isVisible() && q->testAttribute(Qt::WA_OutsideWSRange)) {
                  q->setAttribute(Qt::WA_OutsideWSRange, false);
      
                  // put the window in its place and show it
                  q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h)));
                  data.crect.setRect(x, y, w, h);
                  show_sys();
              } else {
                  QRect r = QRect(x, y, w, h);
                  data.crect = r;
                  q->internalWinId()->SetRect(TRect(TPoint(x, y), TSize(w, h)));
                  topData()->normalGeometry = data.crect;
              }
          }
      

      The Qt::WA_OutsideWSRange attribute is therefore set.

      5. QWidget::setWindowState() calls QWidget::setGeometry(), which calls QWidget::setGeometry_sys with a non-zero size. This ends up in the last else

      {...}

      block in the snippet above.

      6. QWidget::showFullScreen() now calls QWidget::show(), which calls down to QWidget::show_sys(). Because Qt::WA_OutsideWSRange is set, this returns without activating the application's window.

      The problem therefore is that QWidget::setGeometry_sys() does not clear the Qt::WA_OutsideWSRange flag, when the following conditions hold:

      • the new geometry is not out-of-range
      • the widget has not yet been shown

      The attached patch corrects this; it needs to be tested to check that no regressions are introduced.

      Attachments

        1. patch.diff
          2 kB
        2. SimpleTest.zip
          52 kB

        Issue Links

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

          Activity

            People

              gastockw Gareth Stockwell
              gastockw Gareth Stockwell
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes