aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/generator/shiboken/cppgenerator.cpp
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-05-16 12:24:00 +0200
committerChristian Tismer <tismer@stackless.com>2023-03-21 08:49:56 +0100
commite8095467f7d0332cc0987e7c541de9906e19fece (patch)
treec414491f86f34308a051bdb781581b23431a4e20 /sources/shiboken6/generator/shiboken/cppgenerator.cpp
parent18812159a8cd5295ac8d51e37f9021ad21434b90 (diff)
Implement multiple inheritance correctly, compatible version
PySide does not implement multiple inheritance. Please see "About Multiple Inheritance in Python" at the issue. This patch just supports the `__init__` call. A more consequent implementation will follow that supports multiple inheritance with every method. [ChangeLog][pyside6] Cooperative multiple inheritance is now implemented for all __init__ methods. Fixes: PYSIDE-1564 Change-Id: I8df805d22c2052c3a9747420a86341f64e29a5ad Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/shiboken6/generator/shiboken/cppgenerator.cpp')
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 63fc65f19..8563aec8e 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -2297,11 +2297,12 @@ void CppGenerator::writeMethodWrapperPreamble(TextStream &s,const OverloadData &
initPythonArguments = minArgs != maxArgs || maxArgs > 1;
}
- if (needsArgumentErrorHandling(overloadData)) {
- s << R"(Shiboken::AutoDecRef errInfo{};
-static const char fullName[] = ")" << fullPythonFunctionName(rfunc, true)
- << "\";\nSBK_UNUSED(fullName)\n";
- }
+ if (needsArgumentErrorHandling(overloadData))
+ s << "Shiboken::AutoDecRef errInfo{};\n";
+
+ s << "static const char fullName[] = \"" << fullPythonFunctionName(rfunc, true)
+ << "\";\nSBK_UNUSED(fullName)\n";
+
if (maxArgs > 0) {
s << "int overloadId = -1;\n"
<< PYTHON_TO_CPPCONVERSION_STRUCT << ' ' << PYTHON_TO_CPP_VAR;
@@ -2389,6 +2390,12 @@ void CppGenerator::writeConstructorWrapper(TextStream &s, const OverloadData &ov
if (overloadData.maxArgs() > 0)
writeOverloadedFunctionDecisor(s, overloadData, errorReturn);
+ // Handles Python Multiple Inheritance
+ QString pre = needsMetaObject ? u"bool usesPyMI = "_s : u""_s;
+ s << "\n// PyMI support\n"
+ << pre << "Shiboken::callInheritedInit(self, args, kwds, fullName);\n"
+ << "if (PyErr_Occurred())\n" << indent << errorReturn << outdent << "\n";
+
writeFunctionCalls(s, overloadData, classContext, errorReturn);
s << '\n';
@@ -2423,7 +2430,7 @@ void CppGenerator::writeConstructorWrapper(TextStream &s, const OverloadData &ov
<< "PySide::Signal::updateSourceObject(self);\n"
<< "metaObject = cptr->metaObject(); // <- init python qt properties\n"
<< "if (!errInfo.isNull() && PyDict_Check(errInfo.object())) {\n" << indent
- << "if (!PySide::fillQtProperties(self, metaObject, errInfo))\n" << indent
+ << "if (!PySide::fillQtProperties(self, metaObject, errInfo, usesPyMI))\n" << indent
<< "return " << returnErrorWrongArguments(overloadData, errorReturn) << ";\n"
<< outdent << outdent
<< "};\n";