diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-08-19 09:01:29 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-08-19 22:09:52 +0200 |
commit | 3a7856eb4b129449da8fd3c9b7185a4cb2d9cc68 (patch) | |
tree | dd60ba6b8ac7397b347aebc4e801d37c9028e4df | |
parent | 29ab4674dc90c216ab17c7a8022f529f9a46eef7 (diff) | |
parent | cb93ce335cda4b8a8214350b157c55f0c80062d9 (diff) |
Merge "Merge remote-tracking branch 'origin/5.13' into 5.14"
13 files changed, 68 insertions, 38 deletions
diff --git a/build_scripts/utils.py b/build_scripts/utils.py index 5375e9f8a..dc90d99b7 100644 --- a/build_scripts/utils.py +++ b/build_scripts/utils.py @@ -1141,7 +1141,8 @@ def run_instruction(instruction, error, initial_env=None): def acceptCITestConfiguration(hostOS, hostOSVer, targetArch, compiler): # Disable unsupported CI configs for now # NOTE: String must match with QT CI's storagestruct thrift - if hostOSVer in ["WinRT_10", "WebAssembly", "Ubuntu_18_04"]: + if hostOSVer in ["WinRT_10", "WebAssembly", "Ubuntu_18_04"] \ + or hostOSVer.startswith("SLES_"): print("Disabled " + hostOSVer + " from Coin configuration") return False # With 5.11 CI will create two sets of release binaries, one with msvc 2015 and one with msvc 2017 diff --git a/sources/pyside2-tools b/sources/pyside2-tools -Subproject b921df17318a67f846ff9a86e047119f2e4bc4b +Subproject e067832f2864c30e90cb2a25b840775ae2a3497 diff --git a/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport.xml.in b/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport.xml.in index 7949b2daa..ff078d19a 100644 --- a/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport.xml.in +++ b/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport.xml.in @@ -40,7 +40,6 @@ ****************************************************************************/ --> <typesystem package="PySide2.QtPrintSupport"> - <load-typesystem name="QtGui/typesystem_gui.xml" generate="no"/> <load-typesystem name="QtWidgets/typesystem_widgets.xml" generate="no"/> <load-typesystem name="QtPrintSupport/typesystem_printsupport_common.xml" generate="yes"/> </typesystem> diff --git a/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport_common.xml b/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport_common.xml index c11a6e046..487103875 100644 --- a/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport_common.xml +++ b/sources/pyside2/PySide2/QtPrintSupport/typesystem_printsupport_common.xml @@ -40,6 +40,7 @@ ****************************************************************************/ --> <typesystem package="PySide2.QtPrintSupport"> + <load-typesystem name="QtWidgets/typesystem_widgets.xml" generate="no"/> <object-type name="QPageSetupDialog"> <modify-function signature="exec()" rename="exec_" allow-thread="yes"/> diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp index 3e1bab97b..93f7321aa 100644 --- a/sources/pyside2/PySide2/glue/qtcore.cpp +++ b/sources/pyside2/PySide2/glue/qtcore.cpp @@ -1289,7 +1289,7 @@ Shiboken::AutoDecRef emptyTuple(PyTuple_New(0)); PyObject *pyTimer = reinterpret_cast<PyTypeObject *>(Shiboken::SbkType<QTimer>())->tp_new(Shiboken::SbkType<QTimer>(), emptyTuple, 0); reinterpret_cast<PyTypeObject *>(Shiboken::SbkType<QTimer>())->tp_init(pyTimer, emptyTuple, 0); -QTimer * timer = %CONVERTTOCPP[QTimer *](pyTimer); +auto timer = %CONVERTTOCPP[QTimer *](pyTimer); //XXX /|\ omitting this space crashes shiboken! Shiboken::AutoDecRef result( PyObject_CallMethod(pyTimer, @@ -1484,8 +1484,7 @@ if (PySide::SignalManager::registerMetaMethod(%1, signalName.mid(1).toLatin1().d if (!PyObject_TypeCheck(%1, PySideSignalInstanceTypeF())) goto Sbk_%TYPEFunc_%FUNCTION_NAME_TypeError; PySideSignalInstance *signalInstance = reinterpret_cast<PySideSignalInstance *>(%1); -QObject * sender = %CONVERTTOCPP[QObject *](PySide::Signal::getObject(signalInstance)); -//XXX /|\ omitting this space crashes shiboken! +auto sender = %CONVERTTOCPP[QObject *](PySide::Signal::getObject(signalInstance)); QSignalTransition *%0 = %CPPSELF->%FUNCTION_NAME(sender, PySide::Signal::getSignature(signalInstance),%2); %PYARG_0 = %CONVERTTOPYTHON[QSignalTransition *](%0); // @snippet qstate-addtransition-2 diff --git a/sources/pyside2/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp b/sources/pyside2/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp index d4dde36bc..db11e22f8 100644 --- a/sources/pyside2/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp +++ b/sources/pyside2/doc/codesnippets/examples/dialogs/standarddialogs/dialog.cpp @@ -49,32 +49,32 @@ ****************************************************************************/ //! [0] - i = QInputDialog().getInteger(self, self.tr("QInputDialog().getInteger()"), - self.tr("Percentage:"), 25, 0, 100, 1, ok) + i, ok = QInputDialog().getInteger(self, "QInputDialog().getInteger()", + "Percentage:", 25, 0, 100, 1) if ok: - self.integerLabel.setText(self.tr("%1%").arg(i)) + self.integerLabel.setText("{}%".format(i)) //! [0] //! [1] - d = QInputDialog().getDouble(self, self.tr("QInputDialog().getDouble()"), - self.tr("Amount:"), 37.56, -10000, 10000, 2, ok) + d, ok = QInputDialog().getDouble(self, "QInputDialog().getDouble()", + "Amount:", 37.56, -10000, 10000, 2) if ok: - doubleLabel.setText(QString("$%1").arg(d)) + doubleLabel.setText("${}".format()) //! [1] //! [2] - items = [self.tr("Spring"), self.tr("Summer"), self.tr("Fall"), self.tr("Winter")] + items = ["Spring", "Summer", "Fall", "Winter"] - item = QInputDialog().getItem(self, self.tr("QInputDialog().getItem()"), - selftr("Season:"), items, 0, False, ok) + item, ok = QInputDialog().getItem(self, "QInputDialog().getItem()", + "Season:", items, 0, False) if ok and not item.isEmpty(): itemLabel.setText(item) //! [2] //! [3] - text = QInputDialog::getText(self, self.tr("QInputDialog().getText()"), - self.tr("User name:"), QLineEdit.Normal, - QDir().home().dirName(), ok) + text, ok = QInputDialog().getText(self, "QInputDialog().getText()", + "User name:", QLineEdit.Normal, + QDir().home().dirName()) if ok and text: textLabel.setText(text) //! [3] diff --git a/sources/pyside2/tests/QtCore/qslot_object_test.py b/sources/pyside2/tests/QtCore/qslot_object_test.py index b8d5513ff..7a2691a06 100644 --- a/sources/pyside2/tests/QtCore/qslot_object_test.py +++ b/sources/pyside2/tests/QtCore/qslot_object_test.py @@ -31,7 +31,10 @@ import unittest from PySide2 import QtCore -global qApp +""" +This is a simple slot test that was updated to use the qApp "macro". +It is implicitly in builtins and does not need an import. +""" class objTest(QtCore.QObject): @@ -41,21 +44,15 @@ class objTest(QtCore.QObject): self.ok = False def slot(self): - global qApp - self.ok = True qApp.quit() - class slotTest(unittest.TestCase): def quit_app(self): - global qApp - qApp.quit() def testBasic(self): - global qApp timer = QtCore.QTimer() timer.setInterval(100) @@ -71,6 +68,5 @@ class slotTest(unittest.TestCase): if __name__ == '__main__': - global qApp - qApp = QtCore.QCoreApplication([]) + QtCore.QCoreApplication() unittest.main() diff --git a/sources/shiboken2/doc/typesystemvariables.rst b/sources/shiboken2/doc/typesystemvariables.rst index b1b9bbfe6..73d4dd12c 100644 --- a/sources/shiboken2/doc/typesystemvariables.rst +++ b/sources/shiboken2/doc/typesystemvariables.rst @@ -150,6 +150,8 @@ Variables since it otherwise would be indistinguishable from the pointer assignment above. + It is possible to use "auto" as type. + .. _converttopython: **%CONVERTTOPYTHON[CPPTYPE]** diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index b86a5eb46..5a4aa8eba 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -5362,7 +5362,7 @@ void CppGenerator::writeGetattroFunction(QTextStream &s, GeneratorContext &conte s << INDENT << "PyTypeObject *tp = Py_TYPE(self);" << endl; s << INDENT << "PyErr_Format(PyExc_AttributeError," << endl; s << INDENT << " \"'%.50s' object has no attribute '%.400s'\"," << endl; - s << INDENT << " tp->tp_name, PyBytes_AS_STRING(name));" << endl; + s << INDENT << " tp->tp_name, Shiboken::String::toCString(name));" << endl; s << INDENT << "return nullptr;" << endl; } s << INDENT << "} else {" << endl; diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index e41c91716..34e43a4c7 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -2047,7 +2047,7 @@ void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVa QString varName = list.at(1).trimmed(); if (!varType.isEmpty()) { const QString conversionSignature = conversionType->cppSignature(); - if (varType != conversionSignature) + if (varType != QLatin1String("auto") && varType != conversionSignature) qFatal("%s", qPrintable(msgConversionTypesDiffer(varType, conversionSignature))); c << getFullTypeName(conversionType) << ' ' << varName; writeMinimalConstructorExpression(c, conversionType); diff --git a/sources/shiboken2/libshiboken/signature.cpp b/sources/shiboken2/libshiboken/signature.cpp index 7eaf35e1c..07ef366ba 100644 --- a/sources/shiboken2/libshiboken/signature.cpp +++ b/sources/shiboken2/libshiboken/signature.cpp @@ -188,8 +188,12 @@ _get_class_of_descr(PyObject *ob) } static PyObject * -GetClassOfFunc(PyObject *ob) +GetClassOrModOf(PyObject *ob) { + /* + * Return the type or module of a function or type. + * The purpose is finally to use the name of the object. + */ if (PyType_Check(ob)) { // PySide-928: The type case must do refcounting like the others as well. Py_INCREF(ob); @@ -203,7 +207,7 @@ GetClassOfFunc(PyObject *ob) return _get_class_of_descr(ob); if (Py_TYPE(ob) == &PyWrapperDescr_Type) return _get_class_of_descr(ob); - Py_FatalError("unexpected type in GetClassOfFunc"); + Py_FatalError("unexpected type in GetClassOrModOf"); return nullptr; } @@ -228,7 +232,7 @@ compute_name_key(PyObject *ob) if (PyType_Check(ob)) return GetTypeKey(ob); Shiboken::AutoDecRef func_name(get_funcname(ob)); - Shiboken::AutoDecRef type_key(GetTypeKey(GetClassOfFunc(ob))); + Shiboken::AutoDecRef type_key(GetTypeKey(GetClassOrModOf(ob))); return Py_BuildValue("(OO)", type_key.object(), func_name.object()); } @@ -268,7 +272,7 @@ name_key_to_func(PyObject *ob) PyObject *ret = PyDict_GetItem(pyside_globals->map_dict, name_key); if (ret == nullptr) { // do a lazy initialization - Shiboken::AutoDecRef type_key(GetTypeKey(GetClassOfFunc(ob))); + Shiboken::AutoDecRef type_key(GetTypeKey(GetClassOrModOf(ob))); PyObject *type = PyDict_GetItem(pyside_globals->map_dict, type_key); if (type == nullptr) @@ -365,7 +369,7 @@ GetSignature_Function(PyObject *obfunc, const char *modifier) // make sure that we look into PyCFunction, only... if (Py_TYPE(obfunc) == PepFunction_TypePtr) Py_RETURN_NONE; - Shiboken::AutoDecRef obtype_mod(GetClassOfFunc(obfunc)); + Shiboken::AutoDecRef obtype_mod(GetClassOrModOf(obfunc)); Shiboken::AutoDecRef type_key(GetTypeKey(obtype_mod)); if (type_key.isNull()) Py_RETURN_NONE; @@ -682,10 +686,16 @@ handle_doc(PyObject *ob, PyObject *old_descr) { init_module_1(); init_module_2(); - Shiboken::AutoDecRef ob_type(GetClassOfFunc(ob)); - auto *type = reinterpret_cast<PyTypeObject *>(ob_type.object()); - if (handle_doc_in_progress || strncmp(type->tp_name, "PySide2.", 8) != 0) - return PyObject_CallMethod(old_descr, const_cast<char *>("__get__"), const_cast<char *>("(O)"), ob); + Shiboken::AutoDecRef ob_type_mod(GetClassOrModOf(ob)); + const char *name; + if (PyModule_Check(ob_type_mod)) + name = PyModule_GetName(ob_type_mod); + else + name = reinterpret_cast<PyTypeObject *>(ob_type_mod.object())->tp_name; + if (handle_doc_in_progress || name == nullptr + || strncmp(name, "PySide2.", 8) != 0) + return PyObject_CallMethod(old_descr, const_cast<char *>("__get__"), + const_cast<char *>("(O)"), ob); handle_doc_in_progress++; PyObject *res = PyObject_CallFunction( pyside_globals->make_helptext_func, @@ -728,7 +738,9 @@ static int pyside_set___signature__(PyObject *op, PyObject *value) { // By this additional check, this function refuses write access. - if (get_signature_intern(op, nullptr)) { + // We consider both nullptr and Py_None as not been written. + Shiboken::AutoDecRef has_val(get_signature_intern(op, nullptr)); + if (!(has_val.isNull() || has_val == Py_None)) { PyErr_Format(PyExc_AttributeError, "Attribute '__signature__' of '%.50s' object is not writable", Py_TYPE(op)->tp_name); diff --git a/sources/shiboken2/tests/samplebinding/objecttype_test.py b/sources/shiboken2/tests/samplebinding/objecttype_test.py index bda14c69c..f1a06c2b1 100644 --- a/sources/shiboken2/tests/samplebinding/objecttype_test.py +++ b/sources/shiboken2/tests/samplebinding/objecttype_test.py @@ -118,5 +118,13 @@ class ObjectTypeTest(unittest.TestCase): self.assertLess(abs(before - after), 5) + def testInvalidProperty(self): + o = ObjectType() + try: + o.typo + self.assertFail() + except AttributeError as error: + self.assertEqual(error.args[0], "'sample.ObjectType' object has no attribute 'typo'") + if __name__ == '__main__': unittest.main() diff --git a/sources/shiboken2/tests/smartbinding/smart_pointer_test.py b/sources/shiboken2/tests/smartbinding/smart_pointer_test.py index e07856e61..e1883c7cc 100644 --- a/sources/shiboken2/tests/smartbinding/smart_pointer_test.py +++ b/sources/shiboken2/tests/smartbinding/smart_pointer_test.py @@ -175,5 +175,17 @@ class SmartPointerTests(unittest.TestCase): self.assertEqual(len(ptrToObjList), 0) self.assertEqual(objCount(), 1) + def testInvalidParameter(self): + # Create Obj. + o = Obj() + # Create a shared pointer to an Obj together with an Obj. + ptrToObj = o.giveSharedPtrToObj() + try: + ptrToObj.typo + self.assertFail() + except AttributeError as error: + self.assertEqual(error.args[0], "'smart.SharedPtr_Obj' object has no attribute 'typo'") + + if __name__ == '__main__': unittest.main() |