qt5base-lts/tests/manual/qlayout
Thomas Fischer 983dde1f2f Avoid adding widget to its own layout
Widgets and layouts added or inserted to a layout are checked for:
- Not being NULL
- Not being the parent widget of a layout or the layout itself,
  respectively

Without this commit, adding a widget to its own layout would result in a
CPU-hogging infinite loop. Now, a warning is written to stderr and the
add or insert function call is ignored.

The checks are implemented as public functions of QLayoutPrivate and
thus accessible in QLayout's descendants to be used in various
"addWidget", "insertWidget", etc functions.

Unlike 'classical' layouts like QGridLayout, QFormLayout does indeed
accept widgets that are NULL. To not break this behavior, any call for
the check functions first tests if the widget or layout, respectively,
to test is NULL or not and calls the check only in the latter case.

Automated tests for QBoxLayout, QGridLayout, and QFormLayout were added.
For an unpatched Qt 5.3, each of those automated tests will freeze as
explained in QTBUG-40609. For a fixed version, warning messages about
invalid parameters to addWidget/addLayout/... calls will be read by
QTest::ignoreMessage, resulting in a passed test.

Change-Id: I1522d5727e643da3f7c025755975aca9f482676d
Task-number: QTBUG-40609
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2014-09-05 00:05:45 +02:00
..
gridwidget.cpp Avoid adding widget to its own layout 2014-09-05 00:05:45 +02:00
gridwidget.h Update manualtests license to say "part of test suite". 2013-05-26 20:54:51 +02:00
hbwidget.cpp Avoid adding widget to its own layout 2014-09-05 00:05:45 +02:00
hbwidget.h Update manualtests license to say "part of test suite". 2013-05-26 20:54:51 +02:00
main.cpp Update manualtests license to say "part of test suite". 2013-05-26 20:54:51 +02:00
mainwindow.cpp Update manualtests license to say "part of test suite". 2013-05-26 20:54:51 +02:00
mainwindow.h Update manualtests license to say "part of test suite". 2013-05-26 20:54:51 +02:00
qlayout.pro Modified vertical alignments of simple widgets on OSX 2012-10-18 21:45:46 +02:00
vbwidget.cpp Avoid adding widget to its own layout 2014-09-05 00:05:45 +02:00
vbwidget.h Update manualtests license to say "part of test suite". 2013-05-26 20:54:51 +02:00