diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-03-18 15:47:30 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-03-20 01:00:50 +0100 |
commit | 2e5cdd6bd8e99544fd9370900d30edda2c05c6f9 (patch) | |
tree | d832051067b428c4cd99872741e30c12e24e51b8 /sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp | |
parent | 719277aee248afe75abfac77414540827517ad3f (diff) |
shiboken: Fix classes with virtual destructors not being considered polymorphic
Previously, the polymorphic attribute was set in
AbstractMetaClass::addFunction() depending on hasVirtualDestructor().
This does not work when the destructor is the last function traversed.
Modify setHasVirtualDestructor() to set the hasVirtuals and
polymorphic attributes, too.
Fixes: PYSIDE-1246
Change-Id: If7b32a05110f96b5c4befde5f1d37475c9a5f240
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp b/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp index b85a022b3..f2e15fdb0 100644 --- a/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp +++ b/sources/shiboken2/ApiExtractor/tests/testabstractmetaclass.cpp @@ -195,6 +195,33 @@ public: QCOMPARE(funcC->implementingClass(), c); } +void TestAbstractMetaClass::testVirtualBase() +{ + const char cppCode[] =R"CPP( +class Base { +public: + virtual ~Base() = default; +}; +class Derived : public Base {}; +)CPP"; + + const char xmlCode[] = R"XML( +<typesystem package="Foo"> + <object-type name='Base'/> + <object-type name='Derived'/> +</typesystem> +)XML"; + QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode)); + QVERIFY(!builder.isNull()); + AbstractMetaClassList classes = builder->classes(); + auto base = AbstractMetaClass::findClass(classes, QLatin1String("Base")); + QVERIFY(base); + QVERIFY(base->isPolymorphic()); + auto derived = AbstractMetaClass::findClass(classes, QLatin1String("Derived")); + QVERIFY(derived); + QVERIFY(derived->isPolymorphic()); +} + void TestAbstractMetaClass::testDefaultValues() { const char* cppCode ="\ |