diff options
| author | Christian Tismer <tismer@stackless.com> | 2020-11-18 18:25:07 +0100 |
|---|---|---|
| committer | Christian Tismer <tismer@stackless.com> | 2020-11-23 15:32:49 +0000 |
| commit | b6e57864e5f4d470196f7425c631981de6d1aeb4 (patch) | |
| tree | 8cebaae65fb291da2ef9fc89d87fa566243a65ef /sources/pyside6/libpyside/pyside.cpp | |
| parent | b7c13a77f48baf5fdfa0371fe49a1a11e35ea8df (diff) | |
cppgenerator: rework keyword handling regarding unknown keywords
PySide has a distinction between functions with simple arguments and
functions with keyword arguments for optional keywords.
When a function has keywords specified in one or more signature
branch, it gets the METH_KEYWORDS flag. In this case, it is checked
that no argument is given positional and per keyword at the same time.
Completely forgotten was to check which keywords are allowed in that
branch, if at all. The problem was much complicated because
constructors can contain extra signals and properties.
At the same time, all further error messages are generated with Python.
This adds necessary flexibility when features are active.
All PyBuildValue objects were refcount leaking. That has been replaced
by static createStaticString expressions.
The `argNames` structure is no longer needed by the improved algorithm.
Change-Id: Ic297912c47231720f61c7d4b79b46a1e376a9941
Fixes: PYSIDE-1305
Task-number: PYSIDE-1019
Pick-to: 5.15
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside6/libpyside/pyside.cpp')
| -rw-r--r-- | sources/pyside6/libpyside/pyside.cpp | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/sources/pyside6/libpyside/pyside.cpp b/sources/pyside6/libpyside/pyside.cpp index 3eca161fd..7c8b613d3 100644 --- a/sources/pyside6/libpyside/pyside.cpp +++ b/sources/pyside6/libpyside/pyside.cpp @@ -121,38 +121,36 @@ static bool _setProperty(PyObject *qObj, PyObject *name, PyObject *value, bool * return true; } -bool fillQtProperties(PyObject *qObj, const QMetaObject *metaObj, PyObject *kwds, const char **blackList, unsigned int blackListSize) +bool fillQtProperties(PyObject *qObj, const QMetaObject *metaObj, PyObject *kwds) { PyObject *key, *value; Py_ssize_t pos = 0; while (PyDict_Next(kwds, &pos, &key, &value)) { - if (!blackListSize || !std::binary_search(blackList, blackList + blackListSize, std::string(Shiboken::String::toCString(key)))) { - QByteArray propName(Shiboken::String::toCString(key)); - bool accept = false; - if (metaObj->indexOfProperty(propName) != -1) { - if (!_setProperty(qObj, key, value, &accept)) - return false; - } else { - propName.append("()"); - if (metaObj->indexOfSignal(propName) != -1) { - accept = true; - propName.prepend('2'); - if (!PySide::Signal::connect(qObj, propName, value)) - return false; - } - } - if (!accept) { - // PYSIDE-1019: Allow any existing attribute in the constructor. - if (!_setProperty(qObj, key, value, &accept)) + QByteArray propName(Shiboken::String::toCString(key)); + bool accept = false; + if (metaObj->indexOfProperty(propName) != -1) { + if (!_setProperty(qObj, key, value, &accept)) + return false; + } else { + propName.append("()"); + if (metaObj->indexOfSignal(propName) != -1) { + accept = true; + propName.prepend('2'); + if (!PySide::Signal::connect(qObj, propName, value)) return false; } - if (!accept) { - PyErr_Format(PyExc_AttributeError, "'%s' is not a Qt property or a signal", - propName.constData()); + } + if (!accept) { + // PYSIDE-1019: Allow any existing attribute in the constructor. + if (!_setProperty(qObj, key, value, &accept)) return false; - } + } + if (!accept) { + PyErr_Format(PyExc_AttributeError, "'%s' is not a Qt property or a signal", + propName.constData()); + return false; } } return true; |
