summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libpyside/qsignal.cpp21
-rw-r--r--tests/signals/CMakeLists.txt1
-rw-r--r--tests/signals/bug_311.py42
3 files changed, 56 insertions, 8 deletions
diff --git a/libpyside/qsignal.cpp b/libpyside/qsignal.cpp
index f465a7b9..6c542034 100644
--- a/libpyside/qsignal.cpp
+++ b/libpyside/qsignal.cpp
@@ -250,15 +250,21 @@ char* signal_get_type_name(PyObject* type)
char *typeName = NULL;
if (type->ob_type == &Shiboken::SbkBaseWrapperType_Type) {
Shiboken::SbkBaseWrapperType *objType = reinterpret_cast<Shiboken::SbkBaseWrapperType*>(type);
+ Q_ASSERT(objType->original_name);
typeName = strdup(objType->original_name);
} else {
- //tp_name return the full name
- Shiboken::AutoDecRef otypeName(PyObject_GetAttrString(type, "__name__"));
- typeName = strdup(PyString_AS_STRING(otypeName.object()));
- }
- if (Shiboken::TypeResolver::getType(typeName) == Shiboken::TypeResolver::ObjectType) {
- typeName = reinterpret_cast<char*>(realloc(typeName, strlen(typeName) + 1));
- typeName = strcat(typeName, "*");
+ // Translate python types to Qt names
+ PyTypeObject *objType = reinterpret_cast<PyTypeObject*>(type);
+ if (objType == &PyString_Type)
+ typeName = strdup("QString");
+ else if (objType == &PyInt_Type)
+ typeName = strdup("int");
+ else if (objType == &PyLong_Type)
+ typeName = strdup("long");
+ else if (objType == &PyFloat_Type)
+ typeName = strdup("qreal");
+ else
+ typeName = strdup("object");
}
return typeName;
} else if (PyString_Check(type)) {
@@ -277,7 +283,6 @@ char* signal_build_signature(const char *name, const char *signature)
char* signal_parse_signature(PyObject *args)
{
char *signature = 0;
-
if (args && (PyString_Check(args) || (!PySequence_Check(args) && (args != Py_None))))
return signal_get_type_name(args);
diff --git a/tests/signals/CMakeLists.txt b/tests/signals/CMakeLists.txt
index eda247d2..a69aa061 100644
--- a/tests/signals/CMakeLists.txt
+++ b/tests/signals/CMakeLists.txt
@@ -1,4 +1,5 @@
PYSIDE_TEST(args_dont_match_test.py)
+PYSIDE_TEST(bug_311.py)
PYSIDE_TEST(decorators_test.py)
PYSIDE_TEST(invalid_callback_test.py)
PYSIDE_TEST(lambda_gui_test.py)
diff --git a/tests/signals/bug_311.py b/tests/signals/bug_311.py
new file mode 100644
index 00000000..42ed5f37
--- /dev/null
+++ b/tests/signals/bug_311.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import unittest
+from PySide import QtCore
+from helper import UsesQCoreApplication
+
+class DerivedDate(QtCore.QDate):
+ def __init__(self,y,m,d):
+ super(DerivedDate,self).__init__(y,m,d)
+
+class Emitter(QtCore.QObject):
+ dateSignal1 = QtCore.Signal(QtCore.QDate)
+ dateSignal2 = QtCore.Signal(DerivedDate)
+ tupleSignal = QtCore.Signal(tuple)
+
+class SignaltoSignalTest(UsesQCoreApplication):
+ def myCb(self, dt):
+ self._dt = dt
+
+ def testBug(self):
+ e = Emitter()
+ d = DerivedDate(2010,8,24)
+ self._dt = None
+ e.dateSignal1.connect(self.myCb)
+ e.dateSignal1.emit(d)
+ self.assertEqual(self._dt, d)
+
+ self._dt = None
+ e.dateSignal2.connect(self.myCb)
+ e.dateSignal2.emit(d)
+ self.assertEqual(self._dt, d)
+
+ myTuple = (5, 6, 7)
+ self._dt = None
+ e.tupleSignal.connect(self.myCb)
+ e.tupleSignal.emit(myTuple)
+ self.assertEqual(myTuple, self._dt)
+
+if __name__ == '__main__':
+ unittest.main()
+