aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-23 13:31:50 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-29 18:26:47 +0200
commit510bc5b2cf2196d31e950f16d5cfcf6ee1238f47 (patch)
tree9e8c24faf2ebc76a598aa9013d509aae3444703e /sources/shiboken2/generator/shiboken2/cppgenerator.cpp
parent043e74028e55319654685ad97ef5061eb2fda5d2 (diff)
shiboken2: Correctly generate final classes with protected methods without protected hack
Add a missing check for final class. Amends 170756fa1e5de0ce7ba33521f1eb168d70ad276d. Fixes: PYSIDE-1388 Change-Id: I6b7cd5c9a769838287ac7165bdc2d5ad63b289a1 Reviewed-by: Renato Araujo Oliveira Filho <renato.araujo@kdab.com> Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/generator/shiboken2/cppgenerator.cpp')
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 6ec8c0d3c..676cb4985 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -2188,7 +2188,8 @@ void CppGenerator::writeCppSelfDefinition(QTextStream &s,
Q_ASSERT(!(cppSelfAsReference && hasStaticOverload));
const AbstractMetaClass *metaClass = context.metaClass();
- bool useWrapperClass = avoidProtectedHack() && metaClass->hasProtectedMembers();
+ bool useWrapperClass = avoidProtectedHack() && metaClass->hasProtectedMembers()
+ && !metaClass->attributes().testFlag(AbstractMetaAttributes::FinalCppClass);
Q_ASSERT(!useWrapperClass || context.useWrapper());
QString className;
if (!context.forSmartPointer()) {
@@ -3488,14 +3489,16 @@ void CppGenerator::writeMethodCall(QTextStream &s, const AbstractMetaFunction *f
+ QLatin1String(" *>(") + QLatin1String(CPP_SELF_VAR) + QLatin1Char(')');
if (func->isConstant()) {
if (avoidProtectedHack()) {
+ auto ownerClass = func->ownerClass();
mc << "const_cast<const ::";
- if (func->ownerClass()->hasProtectedMembers()) {
+ if (ownerClass->hasProtectedMembers()
+ && !ownerClass->attributes().testFlag(AbstractMetaAttributes::FinalCppClass)) {
// PYSIDE-500: Need a special wrapper cast when inherited
- const QString selfWrapCast = func->ownerClass() == func->implementingClass()
+ const QString selfWrapCast = ownerClass == func->implementingClass()
? QLatin1String(CPP_SELF_VAR)
- : QLatin1String("reinterpret_cast<") + wrapperName(func->ownerClass())
+ : QLatin1String("reinterpret_cast<") + wrapperName(ownerClass)
+ QLatin1String(" *>(") + QLatin1String(CPP_SELF_VAR) + QLatin1Char(')');
- mc << wrapperName(func->ownerClass());
+ mc << wrapperName(ownerClass);
mc << " *>(" << selfWrapCast << ")->";
}
else {