Plug remaining leaks in tests/auto/widgets/kernel

The usual:

- delete return values of QLayout::takeAt(), replaceWidget()
- delete styles
- delete top-level widgets
- delete actions

Either by naked delete, QScopedPointer or allocation on the
stack instead of the heap.

This fixes the remaining errors in GCC 6.1 Linux ASan runs of
tests/auto/widgets/kernel.

Change-Id: I8cc217be114b2e0edf34ad8d60dbf722f900bb7f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2016-09-28 10:49:57 +02:00
parent f773ddd026
commit 686c44a69b
3 changed files with 18 additions and 15 deletions

View File

@ -329,7 +329,7 @@ void tst_QAction::enabledVisibleInteraction()
void tst_QAction::task200823_tooltip()
{
QAction *action = new QAction("foo", 0);
const QScopedPointer<QAction> action(new QAction("foo", Q_NULLPTR));
QString shortcut("ctrl+o");
action->setShortcut(shortcut);
@ -343,8 +343,8 @@ void tst_QAction::task200823_tooltip()
void tst_QAction::task229128TriggeredSignalWithoutActiongroup()
{
// test without a group
QAction *actionWithoutGroup = new QAction("Test", qApp);
QSignalSpy spyWithoutGroup(actionWithoutGroup, SIGNAL(triggered(bool)));
const QScopedPointer<QAction> actionWithoutGroup(new QAction("Test", Q_NULLPTR));
QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), SIGNAL(triggered(bool)));
QCOMPARE(spyWithoutGroup.count(), 0);
actionWithoutGroup->trigger();
// signal should be emitted

View File

@ -2211,8 +2211,8 @@ void tst_QApplication::noQuitOnHide()
{
int argc = 0;
QApplication app(argc, 0);
QWidget *window1 = new NoQuitOnHideWidget;
window1->show();
NoQuitOnHideWidget window1;
window1.show();
QCOMPARE(app.exec(), 1);
}
@ -2246,12 +2246,12 @@ void tst_QApplication::abortQuitOnShow()
{
int argc = 0;
QApplication app(argc, 0);
QWidget *window1 = new ShowCloseShowWidget(false);
window1->show();
ShowCloseShowWidget window1(false);
window1.show();
QCOMPARE(app.exec(), 0);
QWidget *window2 = new ShowCloseShowWidget(true);
window2->show();
ShowCloseShowWidget window2(true);
window2.show();
QCOMPARE(app.exec(), 1);
}

View File

@ -395,7 +395,8 @@ void tst_QFormLayout::setFormStyle()
QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows);
#endif
widget.setStyle(QStyleFactory::create("windows"));
const QScopedPointer<QStyle> windowsStyle(QStyleFactory::create("windows"));
widget.setStyle(windowsStyle.data());
QCOMPARE(layout.labelAlignment(), Qt::AlignLeft);
QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
@ -406,14 +407,16 @@ void tst_QFormLayout::setFormStyle()
this test is cross platform.. so create dummy styles that
return all the right stylehints.
*/
widget.setStyle(new DummyMacStyle());
DummyMacStyle macStyle;
widget.setStyle(&macStyle);
QCOMPARE(layout.labelAlignment(), Qt::AlignRight);
QVERIFY(layout.formAlignment() == (Qt::AlignHCenter | Qt::AlignTop));
QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::FieldsStayAtSizeHint);
QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows);
widget.setStyle(new DummyQtopiaStyle());
DummyQtopiaStyle qtopiaStyle;
widget.setStyle(&qtopiaStyle);
QCOMPARE(layout.labelAlignment(), Qt::AlignRight);
QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
@ -891,7 +894,7 @@ void tst_QFormLayout::takeAt()
QCOMPARE(layout->count(), 7);
for (int i = 6; i >= 0; --i) {
layout->takeAt(0);
delete layout->takeAt(0);
QCOMPARE(layout->count(), i);
}
}
@ -983,7 +986,7 @@ void tst_QFormLayout::replaceWidget()
QFormLayout::ItemRole role;
// replace editor
layout->replaceWidget(edit1, edit3);
delete layout->replaceWidget(edit1, edit3);
edit1->hide(); // Not strictly needed for the test, but for normal usage it is.
QCOMPARE(layout->indexOf(edit1), -1);
QCOMPARE(layout->indexOf(edit3), editIndex);
@ -994,7 +997,7 @@ void tst_QFormLayout::replaceWidget()
QCOMPARE(rownum, 0);
QCOMPARE(role, QFormLayout::FieldRole);
layout->replaceWidget(label1, label2);
delete layout->replaceWidget(label1, label2);
label1->hide();
QCOMPARE(layout->indexOf(label1), -1);
QCOMPARE(layout->indexOf(label2), labelIndex);