diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-10-31 08:22:55 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-10-31 08:23:11 +0100 |
commit | 1064a14bebdc27dd749d9ec91bce5aa88d7a5d0f (patch) | |
tree | ccae2dcf7db3cecfe5cb648c604aa4b007152ed4 /sources/pyside2/PySide2/glue | |
parent | 67929d31c4ab91b357957a9a47c16a8a6b42cf52 (diff) | |
parent | 403cfed02b017d80361cdb5b9bba8c4aad7a14bf (diff) |
Merge remote-tracking branch 'origin/5.13' into 5.14
Change-Id: I9f31a647fd9d4ad9c854a307f8b5df1be935354a
Diffstat (limited to 'sources/pyside2/PySide2/glue')
-rw-r--r-- | sources/pyside2/PySide2/glue/qtcore.cpp | 43 | ||||
-rw-r--r-- | sources/pyside2/PySide2/glue/qtmultimedia.cpp | 7 |
2 files changed, 37 insertions, 13 deletions
diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp index 4c798aef9..47b3dd6db 100644 --- a/sources/pyside2/PySide2/glue/qtcore.cpp +++ b/sources/pyside2/PySide2/glue/qtcore.cpp @@ -57,24 +57,39 @@ bool py2kStrCheck(PyObject *obj) // @snippet pystring-check // @snippet qsettings-value -QVariant out = %CPPSELF.value(%1, %2); +// If we enter the kwds, means that we have a defaultValue or +// at least a type. +// This avoids that we are passing '0' as defaultValue. +// defaultValue can also be passed as positional argument, +// not only as keyword. +QVariant out; +if (kwds || numArgs > 1) + out = %CPPSELF.value(%1, %2); +else + out = %CPPSELF.value(%1); + PyTypeObject *typeObj = reinterpret_cast<PyTypeObject*>(%PYARG_3); if (typeObj) { if (typeObj == &PyList_Type) { - QByteArrayList valuesList = out.toByteArray().split(','); - const int valuesSize = valuesList.size(); - if (valuesSize > 0) { - PyObject *list = PyList_New(valuesSize); - for (int i = 0; i < valuesSize; i++) { - PyObject *item = PyUnicode_FromString(valuesList[i].data()); - PyList_SET_ITEM(list, i, item); - Py_DECREF(item); - } - %PYARG_0 = list; + QByteArray out_ba = out.toByteArray(); + if (!out_ba.isEmpty()) { + QByteArrayList valuesList = out_ba.split(','); + const int valuesSize = valuesList.size(); + if (valuesSize > 0) { + PyObject *list = PyList_New(valuesSize); + for (int i = 0; i < valuesSize; i++) { + PyObject *item = PyUnicode_FromString(valuesList[i].data()); + PyList_SET_ITEM(list, i, item); + Py_DECREF(item); + } + %PYARG_0 = list; + } else { + %PYARG_0 = %CONVERTTOPYTHON[QVariant](out); + } } else { - %PYARG_0 = %CONVERTTOPYTHON[QVariant](out); + %PYARG_0 = PyList_New(0); } } else if (typeObj == &PyBytes_Type) { QByteArray asByteArray = out.toByteArray(); @@ -94,11 +109,13 @@ if (typeObj) { } else if (typeObj == &PyFloat_Type) { float asFloat = out.toFloat(); %PYARG_0 = PyFloat_FromDouble(asFloat); + } else if (typeObj == &PyBool_Type) { + %PYARG_0 = out.toBool() ? Py_True : Py_False; } // TODO: PyDict_Type and PyTuple_Type } else { - if (out == 0) + if (!out.isValid()) %PYARG_0 = Py_None; else %PYARG_0 = %CONVERTTOPYTHON[QVariant](out); diff --git a/sources/pyside2/PySide2/glue/qtmultimedia.cpp b/sources/pyside2/PySide2/glue/qtmultimedia.cpp index 5a3f3a5e7..cbe1367cb 100644 --- a/sources/pyside2/PySide2/glue/qtmultimedia.cpp +++ b/sources/pyside2/PySide2/glue/qtmultimedia.cpp @@ -44,3 +44,10 @@ QObject * upcastedArg = %CONVERTTOCPP[QObject *](%PYARG_1); %CPPSELF.%FUNCTION_NAME(reinterpret_cast< %ARG1_TYPE >(upcastedArg)); %END_ALLOW_THREADS // @snippet upcast + +// @snippet qvideoframe-bits +%BEGIN_ALLOW_THREADS +%RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(); +%END_ALLOW_THREADS +%PYARG_0 = Shiboken::Buffer::newObject(%0, %CPPSELF.bytesPerLine() * %CPPSELF.height(), Shiboken::Buffer::ReadWrite); +// @snippet qvideoframe-bits |