From 72aadf11a482acebf11d7658b7edb942d9995ff0 Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Wed, 26 Aug 2020 18:10:13 +0200 Subject: 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 Reviewed-by: Christian Tismer --- sources/pyside2/libpyside/pysidesignal.cpp | 2 ++ 1 file changed, 2 insertions(+) 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"); -- cgit v1.2.3