diff options
author | Simo Fält <simo.falt@qt.io> | 2023-05-25 11:23:00 +0300 |
---|---|---|
committer | Simo Fält <simo.falt@qt.io> | 2023-05-25 11:23:00 +0300 |
commit | e31990ada911989dbcef3d4833f77dd054030e2c (patch) | |
tree | e08ea7c0808e1468b3c8bbd83fb189a81d8ebeb0 /sources | |
parent | 40fdea15e6545292212ea6c4acc78c3b2975cbd8 (diff) | |
parent | d135bcccdb609d312993e26b466a853b8d1b3f43 (diff) |
Merge tag 'v5.15.7-lts' into tqtc/lts-5.15-opensourcev5.15.7-lts-lgpl
Qt For Python Release 5.15.7
Change-Id: I49808098e3ba42be4be438cb3536fc25672c7127
Diffstat (limited to 'sources')
21 files changed, 120 insertions, 76 deletions
diff --git a/sources/pyside2/PySide2/QtQml/typesystem_qml.xml b/sources/pyside2/PySide2/QtQml/typesystem_qml.xml index 0a12d44cf..c237a9d57 100644 --- a/sources/pyside2/PySide2/QtQml/typesystem_qml.xml +++ b/sources/pyside2/PySide2/QtQml/typesystem_qml.xml @@ -116,7 +116,14 @@ <object-type name="QQmlAbstractUrlInterceptor"> <enum-type name="DataType"/> </object-type> - <object-type name="QQmlApplicationEngine"/> + <object-type name="QQmlApplicationEngine"> + <!-- PYSIDE-1681: QQmlApplicationEngine constructor, load() and similar need + allow-thread in case there is a message handler installed + (qInstallMessageHandler) --> + <modify-function signature="^QQmlApplicationEngine\(.*\)$" allow-thread="yes"/> + <modify-function signature="load(const QString &)" allow-thread="yes"/> + <modify-function signature="load(const QUrl &)" allow-thread="yes"/> + </object-type> <object-type name="QQmlComponent"> <enum-type name="CompilationMode"/> <enum-type name="Status"/> diff --git a/sources/pyside2/doc/CMakeLists.txt b/sources/pyside2/doc/CMakeLists.txt index ab5d694e7..950e48686 100644 --- a/sources/pyside2/doc/CMakeLists.txt +++ b/sources/pyside2/doc/CMakeLists.txt @@ -152,6 +152,7 @@ configure_file("conf.py.in" "rst/conf.py" @ONLY) add_custom_target("docrsts" COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/rst COMMAND Shiboken2::shiboken2 --generator-set=qtdoc ${docHeader} + --enable-pyside-extensions --include-paths="${QT_INCLUDE_DIR}${PATH_SEP}${pyside2_SOURCE_DIR}${PATH_SEP}${TS_ROOT}" --api-version=${SUPPORTED_QT_VERSION} --typesystem-paths="${QDOC_TYPESYSTEM_PATH}" diff --git a/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst b/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst index 982384629..8da69819e 100644 --- a/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst +++ b/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst @@ -185,3 +185,11 @@ command prompt: .. code-block:: python python main.py + +.. note:: + + `QUiLoader` uses connect() calls taking the function signatures as string + arguments for signal/slot connections. + It is thus unable to handle Python types like `str` or `list` from + custom widgets written in Python since these types are internally mapped + to different C++ types. diff --git a/sources/pyside2/libpyside/pysideqflags.cpp b/sources/pyside2/libpyside/pysideqflags.cpp index b141ce157..8b224f2c8 100644 --- a/sources/pyside2/libpyside/pysideqflags.cpp +++ b/sources/pyside2/libpyside/pysideqflags.cpp @@ -99,12 +99,17 @@ extern "C" { return NULL; } - long valA = PYSIDE_QFLAGS(self)->ob_value; - long valB = getNumberValue(other); - if (self == other) { - result = 1; + switch (op) { + case Py_EQ: + case Py_LE: + case Py_GE: + result = 1; + break; + } } else { + const long valA = PYSIDE_QFLAGS(self)->ob_value; + const long valB = getNumberValue(other); switch (op) { case Py_EQ: result = (valA == valB); diff --git a/sources/pyside2/pyside_version.py b/sources/pyside2/pyside_version.py index 3ee73451b..9ec9b0e70 100644 --- a/sources/pyside2/pyside_version.py +++ b/sources/pyside2/pyside_version.py @@ -39,7 +39,7 @@ major_version = "5" minor_version = "15" -patch_version = "6" +patch_version = "7" # For example: "a", "b", "rc" # (which means "alpha", "beta", "release candidate"). diff --git a/sources/pyside2/tests/QtCore/feature_with_uic_test.py b/sources/pyside2/tests/QtCore/feature_with_uic_test.py index 5b61a4afb..64a620be8 100644 --- a/sources/pyside2/tests/QtCore/feature_with_uic_test.py +++ b/sources/pyside2/tests/QtCore/feature_with_uic_test.py @@ -46,7 +46,7 @@ init_test_paths(False) from helper.usesqapplication import UsesQApplication -from PySide2.QtCore import QLibraryInfo, qVersion +from PySide2.QtCore import QCoreApplication, QLibraryInfo, qVersion from PySide2.QtWidgets import QApplication, QMainWindow if sys.version_info[0] >= 3: diff --git a/sources/pyside2/tests/QtGui/qrasterwindow_test.py b/sources/pyside2/tests/QtGui/qrasterwindow_test.py index f18ceaaf4..1776e5efb 100644 --- a/sources/pyside2/tests/QtGui/qrasterwindow_test.py +++ b/sources/pyside2/tests/QtGui/qrasterwindow_test.py @@ -40,27 +40,6 @@ from helper.usesqapplication import UsesQApplication from PySide2.QtCore import QEvent, QPoint, QRect, QSize, QTimer, Qt from PySide2.QtGui import QColor, QBackingStore, QPaintDevice, QPainter, QWindow, QPaintDeviceWindow, QRasterWindow, QRegion, QStaticText -# QWindow rendering via QBackingStore -class TestBackingStoreWindow(QWindow): - def __init__(self): - super(TestBackingStoreWindow, self).__init__() - self.backingStore = QBackingStore(self) - self.text = QStaticText("BackingStoreWindow") - - def event(self, event): - if event.type() == QEvent.Resize: - self.backingStore.resize(self.size()) - self.render() - elif event.type() == QEvent.UpdateRequest or event.type() == QEvent.Expose: - self.backingStore.flush(QRegion(QRect(QPoint(0, 0), self.size()))) - - return QWindow.event(self, event) - - def render(self): - clientRect = QRect(QPoint(0, 0), self.size()) - painter = QPainter(self.backingStore.paintDevice()) - painter.fillRect(clientRect, QColor(Qt.green)) - painter.drawStaticText(QPoint(10, 10), self.text) # Window using convenience class QRasterWindow class TestRasterWindow(QRasterWindow): @@ -74,19 +53,16 @@ class TestRasterWindow(QRasterWindow): painter.fillRect(clientRect, QColor(Qt.red)) painter.drawStaticText(QPoint(10, 10), self.text) + class QRasterWindowTest(UsesQApplication): def test(self): rasterWindow = TestRasterWindow() rasterWindow.setFramePosition(QPoint(100, 100)) rasterWindow.resize(QSize(400, 400)) rasterWindow.show() - backingStoreWindow = TestBackingStoreWindow() - backingStoreWindow.setFramePosition(QPoint(600, 100)) - backingStoreWindow.resize(QSize(400, 400)) - backingStoreWindow.show() - QTimer.singleShot(100, self.app.quit) self.app.exec_() + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside2/tests/pysidetest/enum_test.py b/sources/pyside2/tests/pysidetest/enum_test.py index d179d6248..a9396383e 100644 --- a/sources/pyside2/tests/pysidetest/enum_test.py +++ b/sources/pyside2/tests/pysidetest/enum_test.py @@ -36,6 +36,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from init_paths import init_test_paths init_test_paths(True) +from PySide2.QtCore import Qt from testbinding import Enum1, TestObjectWithoutNamespace class ListConnectionTest(unittest.TestCase): @@ -46,6 +47,29 @@ class ListConnectionTest(unittest.TestCase): self.assertEqual(TestObjectWithoutNamespace.Enum2.Option3, 3) self.assertEqual(TestObjectWithoutNamespace.Enum2.Option4, 4) + def testFlagComparisonOperators(self): # PYSIDE-1696, compare to self + f1 = Qt.AlignHCenter | Qt.AlignBottom + f2 = Qt.AlignHCenter | Qt.AlignBottom + self.assertTrue(f1 == f1) + self.assertTrue(f1 <= f1) + self.assertTrue(f1 >= f1) + self.assertFalse(f1 != f1) + self.assertFalse(f1 < f1) + self.assertFalse(f1 > f1) + + self.assertTrue(f1 == f2) + self.assertTrue(f1 <= f2) + self.assertTrue(f1 >= f2) + self.assertFalse(f1 != f2) + self.assertFalse(f1 < f2) + self.assertFalse(f1 > f2) + + self.assertTrue(Qt.AlignHCenter < Qt.AlignBottom) + self.assertFalse(Qt.AlignHCenter > Qt.AlignBottom) + self.assertFalse(Qt.AlignBottom < Qt.AlignHCenter) + self.assertTrue(Qt.AlignBottom > Qt.AlignHCenter) + + if __name__ == '__main__': unittest.main() diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp index 1c50328bf..b73670909 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp @@ -895,8 +895,10 @@ static QString enumType(const CXCursor &cursor) // PYSIDE-1228: For "typedef enum { v1, v2 } Foo;", type will return // "Foo" as expected. Care must be taken to exclude real anonymous enums. name = getTypeName(clang_getCursorType(cursor)); - if (name.contains(QLatin1String("(anonymous"))) + if (name.contains(QLatin1String("(unnamed")) // Clang 12.0.1 + || name.contains(QLatin1String("(anonymous"))) { // earlier name.clear(); + } } return name; } diff --git a/sources/shiboken2/ApiExtractor/typesystemparser.cpp b/sources/shiboken2/ApiExtractor/typesystemparser.cpp index d2648d0b4..17195d9ab 100644 --- a/sources/shiboken2/ApiExtractor/typesystemparser.cpp +++ b/sources/shiboken2/ApiExtractor/typesystemparser.cpp @@ -1286,7 +1286,7 @@ ContainerTypeEntry * m_error = QLatin1String("no 'type' attribute specified"); return nullptr; } - const QStringRef typeName = attributes->takeAt(typeIndex).value(); + const QStringRef typeName = attributes->at(typeIndex).value(); ContainerTypeEntry::ContainerKind containerType = containerTypeFromAttribute(typeName); if (containerType == ContainerTypeEntry::NoContainer) { m_error = QLatin1String("there is no container of type ") + typeName.toString(); @@ -1294,6 +1294,7 @@ ContainerTypeEntry * } auto *type = new ContainerTypeEntry(name, containerType, since, currentParentTypeEntry()); applyCommonAttributes(reader, type, attributes); + attributes->removeAt(typeIndex); return type; } @@ -1359,7 +1360,7 @@ NamespaceTypeEntry * } result->setFilePattern(re); } else if (attributeName == QLatin1String("extends")) { - const auto extendsPackageName = attributes->takeAt(i).value(); + const auto extendsPackageName = attributes->at(i).value(); auto allEntries = TypeDatabase::instance()->findNamespaceTypes(name); auto extendsIt = std::find_if(allEntries.cbegin(), allEntries.cend(), [extendsPackageName] (const NamespaceTypeEntry *e) { @@ -1370,6 +1371,7 @@ NamespaceTypeEntry * return nullptr; } result->setExtends(*extendsIt); + attributes->removeAt(i); } else if (attributeName == visibleAttribute()) { const auto attribute = attributes->takeAt(i); visibility = visibilityFromAttribute(attribute.value()); @@ -1621,19 +1623,21 @@ bool TypeSystemParser::parseInjectDocumentation(const QXmlStreamReader &, for (int i = attributes->size() - 1; i >= 0; --i) { const QStringRef name = attributes->at(i).qualifiedName(); if (name == QLatin1String("mode")) { - const QStringRef modeName = attributes->takeAt(i).value(); + const QStringRef modeName = attributes->at(i).value(); mode = docModificationFromAttribute(modeName); if (mode == TypeSystem::DocModificationInvalid) { m_error = QLatin1String("Unknown documentation injection mode: ") + modeName; return false; } + attributes->removeAt(i); } else if (name == formatAttribute()) { - const QStringRef format = attributes->takeAt(i).value(); + const QStringRef format = attributes->at(i).value(); lang = languageFromAttribute(format); if (lang != TypeSystem::TargetLangCode && lang != TypeSystem::NativeCode) { m_error = QStringLiteral("unsupported class attribute: '%1'").arg(format); return false; } + attributes->removeAt(i); } } @@ -1797,12 +1801,13 @@ bool TypeSystemParser::parseCustomConversion(const QXmlStreamReader &, for (int i = attributes->size() - 1; i >= 0; --i) { const QStringRef name = attributes->at(i).qualifiedName(); if (name == classAttribute()) { - const QStringRef languageAttribute = attributes->takeAt(i).value(); + const QStringRef languageAttribute = attributes->at(i).value(); lang = languageFromAttribute(languageAttribute); if (lang != TypeSystem::TargetLangCode && lang != TypeSystem::NativeCode) { m_error = QStringLiteral("unsupported class attribute: '%1'").arg(languageAttribute); return false; } + attributes->removeAt(i); } else if (name == QLatin1String("file")) { sourceFile = attributes->takeAt(i).value().toString(); } else if (name == snippetAttribute()) { @@ -1999,12 +2004,13 @@ bool TypeSystemParser::parseDefineOwnership(const QXmlStreamReader &, for (int i = attributes->size() - 1; i >= 0; --i) { const QStringRef name = attributes->at(i).qualifiedName(); if (name == classAttribute()) { - const QStringRef className = attributes->takeAt(i).value(); + const QStringRef className = attributes->at(i).value(); lang = languageFromAttribute(className); if (lang != TypeSystem::TargetLangCode && lang != TypeSystem::NativeCode) { m_error = QStringLiteral("unsupported class attribute: '%1'").arg(className); return false; } + attributes->removeAt(i); } else if (name == ownershipAttribute()) { ownership = attributes->takeAt(i).value().toString(); } @@ -2067,7 +2073,7 @@ bool TypeSystemParser::parseRemoval(const QXmlStreamReader &, TypeSystem::Language lang = TypeSystem::All; const int classIndex = indexOfAttribute(*attributes, classAttribute()); if (classIndex != -1) { - const QStringRef value = attributes->takeAt(classIndex).value(); + const QStringRef value = attributes->at(classIndex).value(); lang = languageFromAttribute(value); if (lang == TypeSystem::TargetLangCode) // "target" means TargetLangAndNativeCode here lang = TypeSystem::TargetLangAndNativeCode; @@ -2075,6 +2081,7 @@ bool TypeSystemParser::parseRemoval(const QXmlStreamReader &, m_error = QStringLiteral("unsupported class attribute: '%1'").arg(value); return false; } + attributes->removeAt(classIndex); } m_contextStack.top()->functionMods.last().removal = lang; return true; @@ -2118,7 +2125,7 @@ bool TypeSystemParser::parseRename(const QXmlStreamReader &reader, m_error = msgMissingAttribute(modifierAttribute()); return false; } - const QStringRef modifier = attributes->takeAt(modifierIndex).value(); + const QStringRef modifier = attributes->at(modifierIndex).value(); modifierFlag = modifierFromAttribute(modifier); if (modifierFlag == Modification::InvalidModifier) { m_error = QStringLiteral("Unknown access modifier: '%1'").arg(modifier); @@ -2128,6 +2135,7 @@ bool TypeSystemParser::parseRename(const QXmlStreamReader &reader, qCWarning(lcShiboken, "%s", qPrintable(msgUnimplementedAttributeValueWarning(reader, modifierAttribute(), modifier))); } + attributes->removeAt(modifierIndex); } if (mod) @@ -2497,12 +2505,13 @@ bool TypeSystemParser::parseParentOwner(const QXmlStreamReader &, if (!parseArgumentIndex(index, &ao.index, &m_error)) return false; } else if (name == actionAttribute()) { - const QStringRef action = attributes->takeAt(i).value(); + const QStringRef action = attributes->at(i).value(); ao.action = argumentOwnerActionFromAttribute(action); if (ao.action == ArgumentOwner::Invalid) { m_error = QLatin1String("Invalid parent actionr '") + action + QLatin1String("'."); return false; } + attributes->removeAt(i); } } m_contextStack.top()->functionMods.last().argument_mods.last().owner = ao; @@ -2569,19 +2578,21 @@ bool TypeSystemParser::parseInjectCode(const QXmlStreamReader &, for (int i = attributes->size() - 1; i >= 0; --i) { const QStringRef name = attributes->at(i).qualifiedName(); if (name == classAttribute()) { - const QStringRef className = attributes->takeAt(i).value(); + const QStringRef className = attributes->at(i).value(); lang = languageFromAttribute(className); if (lang == TypeSystem::NoLanguage) { m_error = QStringLiteral("Invalid class specifier: '%1'").arg(className); return false; } + attributes->removeAt(i); } else if (name == positionAttribute()) { - const QStringRef value = attributes->takeAt(i).value(); + const QStringRef value = attributes->at(i).value(); position = codeSnipPositionFromAttribute(value); if (position == TypeSystem::CodeSnipPositionInvalid) { m_error = QStringLiteral("Invalid position: '%1'").arg(value); return false; } + attributes->removeAt(i); } } diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt index 8b626af09..c6546021c 100644 --- a/sources/shiboken2/CMakeLists.txt +++ b/sources/shiboken2/CMakeLists.txt @@ -144,7 +144,7 @@ endif() # Build with Address sanitizer enabled if requested. # This may break things, so use at your own risk. if (SANITIZE_ADDRESS AND NOT MSVC) - set_sanitize_address() + setup_sanitize_address() endif() # Detect if the python libs were compiled in debug mode diff --git a/sources/shiboken2/data/shiboken_helpers.cmake b/sources/shiboken2/data/shiboken_helpers.cmake index 5e0c6ea72..ad32c3ed5 100644 --- a/sources/shiboken2/data/shiboken_helpers.cmake +++ b/sources/shiboken2/data/shiboken_helpers.cmake @@ -39,7 +39,7 @@ macro(set_debug_build) endif() endmacro() -macro(setup_sanitize_address) +macro(set_sanitize_address) # Currently this does not check that the clang / gcc version used supports Address sanitizer, # so once again, use at your own risk. add_compile_options("-fsanitize=address" "-g" "-fno-omit-frame-pointer") diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp index f90cd312f..60282828a 100644 --- a/sources/shiboken2/generator/generator.cpp +++ b/sources/shiboken2/generator/generator.cpp @@ -43,6 +43,8 @@ #include <QDebug> #include <typedatabase.h> +static const char ENABLE_PYSIDE_EXTENSIONS[] = "enable-pyside-extensions"; + /** * DefaultValue is used for storing default values of types for which code is * generated in different contexts: @@ -169,6 +171,7 @@ struct Generator::GeneratorPrivate QVector<const AbstractMetaType *> instantiatedContainers; QVector<const AbstractMetaType *> instantiatedSmartPointers; AbstractMetaClassList m_invisibleTopNamespaces; + bool m_usePySideExtensions = false; }; Generator::Generator() : m_d(new GeneratorPrivate) @@ -339,11 +342,17 @@ QVector<const AbstractMetaType *> Generator::instantiatedSmartPointers() const Generator::OptionDescriptions Generator::options() const { - return OptionDescriptions(); + return { + {QLatin1String(ENABLE_PYSIDE_EXTENSIONS), + QLatin1String("Enable PySide extensions, such as support for signal/slots,\n" + "use this if you are creating a binding for a Qt-based library.")} + }; } -bool Generator::handleOption(const QString & /* key */, const QString & /* value */) +bool Generator::handleOption(const QString & key, const QString & /* value */) { + if (key == QLatin1String(ENABLE_PYSIDE_EXTENSIONS)) + return ( m_d->m_usePySideExtensions = true); return false; } @@ -615,6 +624,11 @@ bool Generator::isVoidPointer(const AbstractMetaType *type) && type->name() == QLatin1String("void"); } +bool Generator::usePySideExtensions() const +{ + return m_d->m_usePySideExtensions; +} + QString Generator::getFullTypeName(const TypeEntry *type) const { QString result = type->qualifiedCppName(); diff --git a/sources/shiboken2/generator/generator.h b/sources/shiboken2/generator/generator.h index cf6df528f..0cedbd255 100644 --- a/sources/shiboken2/generator/generator.h +++ b/sources/shiboken2/generator/generator.h @@ -244,6 +244,9 @@ public: /// Returns the generator's name. Used for cosmetic purposes. virtual const char *name() const = 0; + /// Returns true if the user enabled PySide extensions (command line option) + bool usePySideExtensions() const; + /** * Retrieves the name of the currently processed module. * While package name is a complete package idetification, e.g. 'PySide.QtCore', diff --git a/sources/shiboken2/generator/main.cpp b/sources/shiboken2/generator/main.cpp index cad6acdd1..fa41cb622 100644 --- a/sources/shiboken2/generator/main.cpp +++ b/sources/shiboken2/generator/main.cpp @@ -612,8 +612,7 @@ int main(int argc, char *argv[]) extractor.setCppFileNames(cppFileNames); extractor.setTypeSystem(typeSystemFileName); - auto shibokenGenerator = dynamic_cast<const ShibokenGenerator *>(generators.constFirst().data()); - const bool usePySideExtensions = shibokenGenerator && shibokenGenerator->usePySideExtensions(); + const bool usePySideExtensions = generators.constFirst().data()->usePySideExtensions(); if (!extractor.run(usePySideExtensions)) { errorPrint(QLatin1String("Error running ApiExtractor.")); diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp index d330d8c18..1b7c786d0 100644 --- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp +++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp @@ -2353,7 +2353,8 @@ bool QtDocGenerator::doSetup() Generator::OptionDescriptions QtDocGenerator::options() const { - return OptionDescriptions() + OptionDescriptions result = Generator::options(); + result << qMakePair(QLatin1String("doc-parser=<parser>"), QLatin1String("The documentation parser used to interpret the documentation\n" "input files (qdoc|doxygen)")) @@ -2368,10 +2369,13 @@ Generator::OptionDescriptions QtDocGenerator::options() const << qMakePair(additionalDocumentationOption() + QLatin1String("=<file>"), QLatin1String("List of additional XML files to be converted to .rst files\n" "(for example, tutorials).")); + return result; } bool QtDocGenerator::handleOption(const QString &key, const QString &value) { + if (Generator::handleOption(key, value)) + return true; if (key == QLatin1String("library-source-dir")) { m_libSourceDir = value; return true; diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index 7743d50a2..6572fca9a 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -1061,7 +1061,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, QString argConv; QTextStream ac(&argConv); - auto argType = static_cast<const PrimitiveTypeEntry *>(arg->type()->typeEntry()); + const auto *argType = arg->type()->typeEntry(); bool convert = argType->isObject() || argType->isValue() || arg->type()->isValuePointer() @@ -1070,11 +1070,11 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, || argType->isEnum() || argType->isContainer() || arg->type()->referenceType() == LValueReference; - if (!convert && argType->isPrimitive()) { - if (argType->basicReferencedTypeEntry()) - argType = argType->basicReferencedTypeEntry(); - convert = !m_formatUnits.contains(argType->name()); + const auto *pte = static_cast<const PrimitiveTypeEntry *>(argType); + if (pte->basicReferencedTypeEntry()) + pte = pte->basicReferencedTypeEntry(); + convert = !m_formatUnits.contains(pte->name()); } Indentor nested; diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index 0f5f09d60..42850e87d 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -46,7 +46,6 @@ static const char AVOID_PROTECTED_HACK[] = "avoid-protected-hack"; static const char PARENT_CTOR_HEURISTIC[] = "enable-parent-ctor-heuristic"; static const char RETURN_VALUE_HEURISTIC[] = "enable-return-value-heuristic"; -static const char ENABLE_PYSIDE_EXTENSIONS[] = "enable-pyside-extensions"; static const char DISABLE_VERBOSE_ERROR_MESSAGES[] = "disable-verbose-error-messages"; static const char USE_ISNULL_AS_NB_NONZERO[] = "use-isnull-as-nb_nonzero"; static const char WRAPPER_DIAGNOSTICS[] = "wrapper-diagnostics"; @@ -2567,7 +2566,8 @@ AbstractMetaFunctionList ShibokenGenerator::getFunctionOverloads(const AbstractM Generator::OptionDescriptions ShibokenGenerator::options() const { - return OptionDescriptions() + OptionDescriptions result = Generator::options(); + result << qMakePair(QLatin1String(AVOID_PROTECTED_HACK), QLatin1String("Avoid the use of the '#define protected public' hack.")) << qMakePair(QLatin1String(DISABLE_VERBOSE_ERROR_MESSAGES), @@ -2575,9 +2575,6 @@ Generator::OptionDescriptions ShibokenGenerator::options() const "but safe few kB on the generated bindings.")) << qMakePair(QLatin1String(PARENT_CTOR_HEURISTIC), QLatin1String("Enable heuristics to detect parent relationship on constructors.")) - << qMakePair(QLatin1String(ENABLE_PYSIDE_EXTENSIONS), - QLatin1String("Enable PySide extensions, such as support for signal/slots,\n" - "use this if you are creating a binding for a Qt-based library.")) << qMakePair(QLatin1String(RETURN_VALUE_HEURISTIC), QLatin1String("Enable heuristics to detect parent relationship on return values\n" "(USE WITH CAUTION!)")) @@ -2586,14 +2583,15 @@ Generator::OptionDescriptions ShibokenGenerator::options() const "the value of boolean casts")) << qMakePair(QLatin1String(WRAPPER_DIAGNOSTICS), QLatin1String("Generate diagnostic code around wrappers")); + return result; } -bool ShibokenGenerator::handleOption(const QString &key, const QString & /* value */) +bool ShibokenGenerator::handleOption(const QString &key, const QString &value) { + if (Generator::handleOption(key, value)) + return true; if (key == QLatin1String(PARENT_CTOR_HEURISTIC)) return (m_useCtorHeuristic = true); - if (key == QLatin1String(ENABLE_PYSIDE_EXTENSIONS)) - return (m_usePySideExtensions = true); if (key == QLatin1String(RETURN_VALUE_HEURISTIC)) return (m_userReturnValueHeuristic = true); if (key == QLatin1String(DISABLE_VERBOSE_ERROR_MESSAGES)) @@ -2695,11 +2693,6 @@ bool ShibokenGenerator::useReturnValueHeuristic() const return m_userReturnValueHeuristic; } -bool ShibokenGenerator::usePySideExtensions() const -{ - return m_usePySideExtensions; -} - bool ShibokenGenerator::useIsNullAsNbNonZero() const { return m_useIsNullAsNbNonZero; diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.h b/sources/shiboken2/generator/shiboken2/shibokengenerator.h index cbe796313..c776ac8c8 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.h +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.h @@ -90,9 +90,6 @@ public: /// Returns a list of all ancestor classes for the given class. AbstractMetaClassList getAllAncestors(const AbstractMetaClass *metaClass) const; - /// Returns true if the user enabled PySide extensions. - bool usePySideExtensions() const; - protected: bool doSetup() override; @@ -564,7 +561,6 @@ private: bool m_useCtorHeuristic = false; bool m_userReturnValueHeuristic = false; - bool m_usePySideExtensions = false; bool m_verboseErrorMessagesDisabled = false; bool m_useIsNullAsNbNonZero = false; bool m_avoidProtectedHack = false; diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp index 113128f5a..7ac7fada2 100644 --- a/sources/shiboken2/libshiboken/basewrapper.cpp +++ b/sources/shiboken2/libshiboken/basewrapper.cpp @@ -560,7 +560,8 @@ PyObject *MakeQAppWrapper(PyTypeObject *type) // protecting from multiple application instances if (!(type == nullptr || qApp_last == Py_None)) { - const char *res_name = PepType_GetNameStr(Py_TYPE(qApp_last)); + const char *res_name = qApp_last != nullptr + ? PepType_GetNameStr(Py_TYPE(qApp_last)) : "<Unknown>"; const char *type_name = PepType_GetNameStr(type); PyErr_Format(PyExc_RuntimeError, "Please destroy the %s singleton before" " creating a new %s instance.", res_name, type_name); diff --git a/sources/shiboken2/shiboken_version.py b/sources/shiboken2/shiboken_version.py index 3ee73451b..9ec9b0e70 100644 --- a/sources/shiboken2/shiboken_version.py +++ b/sources/shiboken2/shiboken_version.py @@ -39,7 +39,7 @@ major_version = "5" minor_version = "15" -patch_version = "6" +patch_version = "7" # For example: "a", "b", "rc" # (which means "alpha", "beta", "release candidate"). |