diff options
author | Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2020-08-26 18:10:13 +0200 |
---|---|---|
committer | Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2020-08-31 11:47:10 +0200 |
commit | 72aadf11a482acebf11d7658b7edb942d9995ff0 (patch) | |
tree | 968047a9b1f423cb7f0914c3aa080250bdba15ea | |
parent | 9a37b64bbee7573578f63334b76a3eca533ea539 (diff) |
Return QVariantList when using list as Signal argument
When determinating the type name for Signal types,
we have special treatment for a couple of Python types
like str, int, float, bool, etc, if the current type
is none of those, we return a generic 'PyObject',
which in most cases works, but not for specific interaction
with WebChannel.
Emiting one of the previous types works out of the box,
but when using:
... = Signal(list)
we get a message stating:
> js: Uncaught TypeError: Cannot read property '0' of null
meaning that list was not really passed correctly.
The solution for this is to use:
... = Signal('QVariantList')
but as a string, not type.
Passing a string means that we will return the same type as string
from the getTypeName function, so this patch adds a condition
to treat Signal(list) as a Signal('QVariantList').
We were using this workaround for some bugs related to QtWebKit,
so it was accepted as solution.
Fixes: PYSIDE-981
Change-Id: I06720ca62426d51decc2ab08d380f7f967460788
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r-- | sources/pyside2/libpyside/pysidesignal.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sources/pyside2/libpyside/pysidesignal.cpp b/sources/pyside2/libpyside/pysidesignal.cpp index 367f85fff..aa215aa45 100644 --- a/sources/pyside2/libpyside/pysidesignal.cpp +++ b/sources/pyside2/libpyside/pysidesignal.cpp @@ -687,6 +687,8 @@ QByteArray getTypeName(PyObject *type) return QByteArrayLiteral("double"); if (objType == &PyBool_Type) return QByteArrayLiteral("bool"); + if (objType == &PyList_Type) + return QByteArrayLiteral("QVariantList"); if (Py_TYPE(objType) == SbkEnumType_TypeF()) return Shiboken::Enum::getCppName(objType); return QByteArrayLiteral("PyObject"); |