QMetaContainer: Allow retrieving the d pointer

This is in line with how QMetaType handles QMetaTypeInterface*. You can
retrieve a const pointer to it.

Task-number: QTBUG-113690
Change-Id: Iaf3c10603dc6049a5553987c90006807867abc0d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 937751f427)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Ulf Hermann 2023-06-19 14:01:06 +02:00 committed by Qt Cherry-pick Bot
parent f0765c556d
commit 8529d537ac
2 changed files with 12 additions and 0 deletions

View File

@ -982,6 +982,8 @@ public:
return a.d() != b.d();
}
const QtMetaContainerPrivate::QMetaSequenceInterface *iface() const { return d(); }
private:
template<typename T>
struct MetaSequence
@ -1176,6 +1178,8 @@ public:
return a.d() != b.d();
}
const QtMetaContainerPrivate::QMetaAssociationInterface *iface() const { return d(); }
private:
template<typename T>
struct MetaAssociation

View File

@ -497,6 +497,10 @@ void tst_QMetaContainer::testSequence()
QVERIFY(metaSequence.compareConstIterator(constIt, constEnd));
metaSequence.destroyConstIterator(constIt);
metaSequence.destroyConstIterator(constEnd);
QVERIFY(metaSequence.iface() != nullptr);
QMetaSequence defaultConstructed;
QVERIFY(defaultConstructed.iface() == nullptr);
}
void tst_QMetaContainer::testAssociation_data()
@ -722,6 +726,10 @@ void tst_QMetaContainer::testAssociation()
QVERIFY(metaAssociation.compareConstIterator(constIt, constEnd));
metaAssociation.destroyConstIterator(constIt);
metaAssociation.destroyConstIterator(constEnd);
QVERIFY(metaAssociation.iface() != nullptr);
QMetaSequence defaultConstructed;
QVERIFY(defaultConstructed.iface() == nullptr);
}
QTEST_MAIN(tst_QMetaContainer)