diff options
| author | Piotr Srebrny <[email protected]> | 2021-04-28 14:37:44 +0200 |
|---|---|---|
| committer | Piotr Srebrny <[email protected]> | 2021-05-11 16:57:17 +0000 |
| commit | 867c0b8d8a53974074b1fff5b132f3ae9f150066 (patch) | |
| tree | 3096671fa5d48c00df7e6d7e0ba7b3738e6932b1 /src/widgets/kernel/qlayout.cpp | |
| parent | 1e85dfacf3479ebbe5a4502895b8b8d93fbe1477 (diff) | |
Do not remove non-widget items when removeWidget() called with nullptr
child->widget() returns null if the layout item is not a widget.
Thus, calling removeWidget(nullptr) will remove all non-widget items
such as layouts or strechers.
Change-Id: I772c1158d0f7e8e2850b6e571b0405a2896f09b8
Pick-to: 6.0 6.1 5.15
Reviewed-by: Tor Arne Vestbø <[email protected]>
Reviewed-by: David Faure <[email protected]>
Diffstat (limited to 'src/widgets/kernel/qlayout.cpp')
| -rw-r--r-- | src/widgets/kernel/qlayout.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 8688e011a03..044176d141f 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -1355,6 +1355,11 @@ QRect QLayout::alignmentRect(const QRect &r) const */ void QLayout::removeWidget(QWidget *widget) { + if (Q_UNLIKELY(!widget)) { + qWarning("QLayout::removeWidget: Cannot remove a null widget."); + return; + } + int i = 0; QLayoutItem *child; while ((child = itemAt(i))) { |
