diff options
| -rw-r--r-- | sources/shiboken6/ApiExtractor/abstractmetalang.cpp | 10 | ||||
| -rw-r--r-- | sources/shiboken6/generator/shiboken/cppgenerator.cpp | 11 | ||||
| -rw-r--r-- | sources/shiboken6/generator/shiboken/headergenerator.cpp | 5 |
3 files changed, 17 insertions, 9 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp index d528fc60c..e80bc4371 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp @@ -872,8 +872,16 @@ static AbstractMetaClass::CppWrapper determineCppWrapper(const AbstractMetaClass return result; } +#ifndef Q_CC_MSVC + // PYSIDE-504: When C++ 11 is used, then the destructor must always be + // declared. Only MSVC can handle this, the others generate a link error. + // See also HeaderGenerator::generateClass(). + if (metaClass->hasPrivateDestructor()) + return result; +#endif + // Need checking for Python overrides? - if (metaClass->isPolymorphic() && !metaClass->hasPrivateDestructor()) + if (metaClass->isPolymorphic()) result |= AbstractMetaClass::CppVirtualMethodWrapper; // Is there anything protected that needs to be made accessible? diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index d206a4c7d..40f98b642 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -3564,8 +3564,9 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr else if (func->ownerClass()) methodCallClassName = func->ownerClass()->qualifiedCppName(); - if (func->ownerClass()) { - if (!avoidProtectedHack() || !func->isProtected()) { + if (auto ownerClass = func->ownerClass()) { + const bool hasWrapper = shouldGenerateCppWrapper(ownerClass); + if (!avoidProtectedHack() || !func->isProtected() || !hasWrapper) { if (func->isStatic()) { mc << "::" << methodCallClassName << "::"; } else { @@ -3575,7 +3576,6 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr + QLatin1String(" *>(") + QLatin1String(CPP_SELF_VAR) + QLatin1Char(')'); if (func->isConstant()) { if (avoidProtectedHack()) { - auto ownerClass = func->ownerClass(); mc << "const_cast<const ::"; if (ownerClass->cppWrapper().testFlag(AbstractMetaClass::CppProtectedHackWrapper)) { // PYSIDE-500: Need a special wrapper cast when inherited @@ -3605,10 +3605,9 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr mc << func->originalName(); } else { if (!func->isStatic()) { - const auto *owner = func->ownerClass(); - const bool directInheritance = context.metaClass() == owner; + const bool directInheritance = context.metaClass() == ownerClass; mc << (directInheritance ? "static_cast" : "reinterpret_cast") - << "<::" << wrapperName(owner) << " *>(" << CPP_SELF_VAR << ")->"; + << "<::" << wrapperName(ownerClass) << " *>(" << CPP_SELF_VAR << ")->"; } if (!func->isAbstract()) diff --git a/sources/shiboken6/generator/shiboken/headergenerator.cpp b/sources/shiboken6/generator/shiboken/headergenerator.cpp index 39e23a680..a2108cc9f 100644 --- a/sources/shiboken6/generator/shiboken/headergenerator.cpp +++ b/sources/shiboken6/generator/shiboken/headergenerator.cpp @@ -161,8 +161,9 @@ void HeaderGenerator::generateClass(TextStream &s, const GeneratorContext &class maxOverrides = 1; //destructor - // PYSIDE-504: When C++ 11 is used, then the destructor must always be written. - // See generator.h for further reference. + // PYSIDE-504: When C++ 11 is used, then the destructor must always be declared. + // See abstractmetalang.cpp, determineCppWrapper() and generator.h for further + // reference. if (!avoidProtectedHack() || !metaClass->hasPrivateDestructor() || alwaysGenerateDestructor) { if (avoidProtectedHack() && metaClass->hasPrivateDestructor()) s << "// C++11: need to declare (unimplemented) destructor because " |
