summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-05-14 15:03:24 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-08-13 17:26:11 +0200
commit19b52e7c1dc2c447c1682f9438ebd37cbfc7d31d (patch)
treed9b9d20b11d3c399809f15585b27671ae7b12dfb /tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
parent743fdd3fe7ad8d3cafa237a202c089fa6ff1c78c (diff)
tst_QFormLayout: use QAutoPointer to simplify test and avoid leak
... in case of a test failure. QAutoPointer is private API, but here we can use it. Change-Id: I45b734385cd13fdea95d0100f2d8152f969612f9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp')
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index ab32643061..c6760000f4 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -38,6 +38,9 @@
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QPushButton>
+
+#include <private/qdialog_p.h>
+
#include <QStyleFactory>
#include <QSharedPointer>
@@ -1196,22 +1199,20 @@ void tst_QFormLayout::layoutAlone()
void tst_QFormLayout::taskQTBUG_27420_takeAtShouldUnparentLayout()
{
QSharedPointer<QFormLayout> outer(new QFormLayout);
- QPointer<QFormLayout> inner = new QFormLayout;
+ QAutoPointer<QFormLayout> holder{new QFormLayout};
+ auto inner = holder.get();
outer->addRow(inner);
QCOMPARE(outer->count(), 1);
QCOMPARE(inner->parent(), outer.data());
QLayoutItem *item = outer->takeAt(0);
- QCOMPARE(item->layout(), inner.data());
+ QCOMPARE(item->layout(), inner);
QVERIFY(!item->layout()->parent());
outer.reset();
- if (inner)
- delete item; // success: a taken item/layout should not be deleted when the old parent is deleted
- else
- QVERIFY(!inner.isNull());
+ QVERIFY(holder); // a taken item/layout should not be deleted when the old parent is deleted
}
void tst_QFormLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){