aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/tests/testreverseoperators.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-11-27 17:11:47 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-11-30 15:53:54 +0000
commit30cdcd7b8e7f70bf6b64450ca622dd4494e3a0ea (patch)
tree044002feaeb24281e9000648a1342073701ee29c /sources/shiboken6/ApiExtractor/tests/testreverseoperators.cpp
parentf4fd97655f20e2ce4d24704056b7a7a9ab9db355 (diff)
shiboken6: Store AbstractMetaFunction using a QSharedPointer
Store the list functions (global / class member) as a QList<QSharedPointer<const AbstractMetaFunction> instead of a raw pointer list. This makes passing around function lists easier and solves the memory leaks caused by mixing cloned and unmodified functions while collecting the overload lists in the generators. - Change the function signatures accordingly - Add a qSharedPointerConstCast() for non-const access. - Restructure the traversing of added functions in the AbstractMetaBuilder - Remove some unused typedefs and functions unearthed by the change Change-Id: I08a6c5243750e3eb3813bc3f7172899ad2b13e22 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/tests/testreverseoperators.cpp')
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testreverseoperators.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/sources/shiboken6/ApiExtractor/tests/testreverseoperators.cpp b/sources/shiboken6/ApiExtractor/tests/testreverseoperators.cpp
index 66dd6edbf..3ad77c86f 100644
--- a/sources/shiboken6/ApiExtractor/tests/testreverseoperators.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testreverseoperators.cpp
@@ -52,9 +52,9 @@ void TestReverseOperators::testReverseSum()
QVERIFY(classA);
QCOMPARE(classA->functions().count(), 4);
- const AbstractMetaFunction* reverseOp = nullptr;
- const AbstractMetaFunction* normalOp = 0;
- for (const AbstractMetaFunction *func : classA->functions()) {
+ AbstractMetaFunctionCPtr reverseOp;
+ AbstractMetaFunctionCPtr normalOp;
+ for (const auto &func : classA->functions()) {
if (func->name() == QLatin1String("operator+")) {
if (func->isReverseOperator())
reverseOp = func;
@@ -63,10 +63,10 @@ void TestReverseOperators::testReverseSum()
}
}
- QVERIFY(normalOp);
+ QVERIFY(!normalOp.isNull());
QVERIFY(!normalOp->isReverseOperator());
QCOMPARE(normalOp->arguments().count(), 1);
- QVERIFY(reverseOp);
+ QVERIFY(!reverseOp.isNull());
QVERIFY(reverseOp->isReverseOperator());
QCOMPARE(reverseOp->arguments().count(), 1);
}
@@ -98,9 +98,9 @@ void TestReverseOperators::testReverseSumWithAmbiguity()
QVERIFY(classB);
QCOMPARE(classB->functions().count(), 4);
- const AbstractMetaFunction *reverseOp = nullptr;
- const AbstractMetaFunction *normalOp = nullptr;
- for (const AbstractMetaFunction *func : classB->functions()) {
+ AbstractMetaFunctionCPtr reverseOp;
+ AbstractMetaFunctionCPtr normalOp;
+ for (const auto &func : classB->functions()) {
if (func->name() == QLatin1String("operator+")) {
if (func->isReverseOperator())
reverseOp = func;
@@ -108,11 +108,11 @@ void TestReverseOperators::testReverseSumWithAmbiguity()
normalOp = func;
}
}
- QVERIFY(normalOp);
+ QVERIFY(!normalOp.isNull());
QVERIFY(!normalOp->isReverseOperator());
QCOMPARE(normalOp->arguments().count(), 1);
QCOMPARE(normalOp->minimalSignature(), QLatin1String("operator+(B,A)"));
- QVERIFY(reverseOp);
+ QVERIFY(!reverseOp.isNull());
QVERIFY(reverseOp->isReverseOperator());
QCOMPARE(reverseOp->arguments().count(), 1);
QCOMPARE(reverseOp->minimalSignature(), QLatin1String("operator+(A,B)"));