diff options
author | Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com> | 2014-12-02 15:45:48 +0100 |
---|---|---|
committer | Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com> | 2014-12-07 12:39:19 +0100 |
commit | 9cb85ada8bc599bbc861371a5d2725c5fc5c73b1 (patch) | |
tree | 8498806f39abe16c1038f868f0324f00a321294d | |
parent | ac79a25aae1a883e1587631ad531ad43b0dc8e8a (diff) |
Fix memory leaks in tst_moc
Change-Id: Id17c4253e7e7a2e4ab7fd9b290481ca90914b782
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
-rw-r--r-- | tests/auto/tools/moc/tst_moc.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 6255082999..d67b3e011a 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -1301,13 +1301,13 @@ public: PrivatePropertyTest(QObject *parent = 0) : QObject(parent), mFoo(0), d (new MyDPointer) {} int foo() { return mFoo ; } void setFoo(int value) { mFoo = value; } - MyDPointer *d_func() {return d;} + MyDPointer *d_func() {return d.data();} signals: void blub4Changed(); void blub5Changed(const QString &newBlub); private: int mFoo; - MyDPointer *d; + QScopedPointer<MyDPointer> d; }; @@ -1411,19 +1411,19 @@ void tst_Moc::constructors() QCOMPARE(mo->indexOfConstructor("CtorTestClass2(QObject*)"), -1); QCOMPARE(mo->indexOfConstructor("CtorTestClass(float,float)"), -1); - QObject *o1 = mo->newInstance(); + QScopedPointer<QObject> o1(mo->newInstance()); QVERIFY(o1 != 0); QCOMPARE(o1->parent(), (QObject*)0); - QVERIFY(qobject_cast<CtorTestClass*>(o1) != 0); + QVERIFY(qobject_cast<CtorTestClass*>(o1.data()) != 0); - QObject *o2 = mo->newInstance(Q_ARG(QObject*, o1)); + QObject *o2 = mo->newInstance(Q_ARG(QObject*, o1.data())); QVERIFY(o2 != 0); - QCOMPARE(o2->parent(), o1); + QCOMPARE(o2->parent(), o1.data()); QString str = QString::fromLatin1("hello"); - QObject *o3 = mo->newInstance(Q_ARG(QString, str)); + QScopedPointer<QObject> o3(mo->newInstance(Q_ARG(QString, str))); QVERIFY(o3 != 0); - QCOMPARE(qobject_cast<CtorTestClass*>(o3)->m_str, str); + QCOMPARE(qobject_cast<CtorTestClass*>(o3.data())->m_str, str); { //explicit constructor |