summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libpyside/pysideproperty.cpp14
-rw-r--r--tests/QtCore/CMakeLists.txt1
-rw-r--r--tests/QtCore/bug_699.py17
3 files changed, 25 insertions, 7 deletions
diff --git a/libpyside/pysideproperty.cpp b/libpyside/pysideproperty.cpp
index 839e55f..4e9b724 100644
--- a/libpyside/pysideproperty.cpp
+++ b/libpyside/pysideproperty.cpp
@@ -168,14 +168,14 @@ int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds)
return 0;
}
- if (pData->constant && (pData->fset || pData->notify)) {
- free(pData);
- PyErr_SetString(PyExc_AttributeError, "A constant property cannot have a WRITE method or a NOTIFY signal.");
- return 0;
-
- }
pData->typeName = PySide::Signal::getTypeName(type);
- return 1;
+
+ if (!pData->typeName)
+ PyErr_SetString(PyExc_TypeError, "Invalid property type or type name.");
+ else if (pData->constant && (pData->fset || pData->notify))
+ PyErr_SetString(PyExc_TypeError, "A constant property cannot have a WRITE method or a NOTIFY signal.");
+
+ return PyErr_Occurred() ? -1 : 1;
}
void qpropertyFree(void *self)
diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt
index 434c8fe..48de2c4 100644
--- a/tests/QtCore/CMakeLists.txt
+++ b/tests/QtCore/CMakeLists.txt
@@ -6,6 +6,7 @@ PYSIDE_TEST(bug_462.py)
PYSIDE_TEST(bug_505.py)
PYSIDE_TEST(bug_515.py)
PYSIDE_TEST(bug_656.py)
+PYSIDE_TEST(bug_699.py)
PYSIDE_TEST(bug_706.py)
PYSIDE_TEST(blocking_signals_test.py)
PYSIDE_TEST(child_event_test.py)
diff --git a/tests/QtCore/bug_699.py b/tests/QtCore/bug_699.py
new file mode 100644
index 0000000..e731b5b
--- /dev/null
+++ b/tests/QtCore/bug_699.py
@@ -0,0 +1,17 @@
+import unittest
+from PySide.QtCore import *
+
+class TestBug699 (unittest.TestCase):
+
+ def defClass(self):
+ class Foo (QObject):
+ def foo(self):
+ pass
+
+ prop = Property(foo, foo)
+
+ def testIt(self):
+ self.assertRaises(TypeError, self.defClass)
+
+if __name__ == '__main__':
+ unittest.main()