tst_QLayout: fix memleak in removeWidget()
A QLayout that was removeItem()ed from its parent layout no longer is deleted by it and has to be deleted manually, which the test function failed to do. To maintain the rest of the test function as faithfully as possible, don't delete the layout right after the removeItem(), but delay until the exit from the test function, using unique_ptr. Amends 867c0b8d8a53974074b1fff5b132f3ae9f150066. Pick-to: 6.9 6.8 6.5 5.15 Change-Id: Ia915d29bda348849033a6b9eb282dcb26a68c383 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
parent
90a82ad8e5
commit
20d5a3cda9
@ -22,6 +22,8 @@
|
||||
|
||||
#include <QtTest/private/qtesthelpers_p.h>
|
||||
|
||||
#include <QtCore/qscopeguard.h>
|
||||
|
||||
using namespace QTestPrivate;
|
||||
|
||||
class tst_QLayout : public QObject
|
||||
@ -392,6 +394,7 @@ void tst_QLayout::removeWidget()
|
||||
QCOMPARE(layout.count(), 1);
|
||||
|
||||
layout.removeItem(childLayout);
|
||||
const auto reaper = qScopeGuard([&] { delete childLayout; });
|
||||
QCOMPARE(layout.count(), 0);
|
||||
|
||||
QVERIFY(!childLayout.isNull());
|
||||
|
Loading…
x
Reference in New Issue
Block a user