aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-11-02 11:16:44 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-11-02 22:05:00 +0100
commit3d8fe66f493f650d6dafb337105ef20645cd7ee2 (patch)
tree18f410e033ed9fb3a5bea4901d50e581fe36e952
parent41f0e7d085fcca73212c7d684338bf8c3e36ddf5 (diff)
Fix some memory leaks in tst_qqmllistmodel.cpp
Change-Id: I5897b2a929700ddb2458a2ab927cb5ec72316274 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp
index 1920c3c35d..0ca86dbb4c 100644
--- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp
+++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp
@@ -741,9 +741,8 @@ void tst_qqmllistmodel::syncError()
component.setData(qml.toUtf8(),
QUrl::fromLocalFile(QString("dummy.qml")));
QTest::ignoreMessage(QtWarningMsg,error.toUtf8());
- QObject *obj = component.create();
- QVERIFY(obj);
- delete obj;
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY2(obj, qPrintable(component.errorString()));
}
/*
@@ -1093,12 +1092,10 @@ void tst_qqmllistmodel::set_model_cache()
{
QQmlEngine eng;
QQmlComponent component(&eng, testFileUrl("setmodelcachelist.qml"));
- QObject *model = component.create();
- QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
+ QScopedPointer<QObject> model(component.create());
+ QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
QVERIFY(model != nullptr);
QVERIFY(model->property("ok").toBool());
-
- delete model;
}
void tst_qqmllistmodel::property_changes()
@@ -1291,15 +1288,13 @@ void tst_qqmllistmodel::signal_handlers()
QQmlEngine eng;
QQmlComponent component(&eng, testFileUrl("signalhandlers.qml"));
- QObject *model = component.create();
- QQmlListModel *lm = qobject_cast<QQmlListModel *>(model);
+ QScopedPointer<QObject> model(component.create());
+ QQmlListModel *lm = qobject_cast<QQmlListModel *>(model.data());
QVERIFY(lm != nullptr);
lm->setDynamicRoles(dynamicRoles);
- QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
+ QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
QVERIFY(model != nullptr);
QVERIFY(model->property("ok").toBool());
-
- delete model;
}
void tst_qqmllistmodel::role_mode_data()