diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2010-09-28 18:07:02 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2010-09-29 15:44:13 -0300 |
commit | eabb9d37a78d1c584fe7e70928f0e820bd6e0afc (patch) | |
tree | cb94c7d95e2ff0112843e877008eadb5bcb9b5e2 | |
parent | 6ad03f2a795563aec47d45d6426639323f981975 (diff) |
Fix bug#372 - "DiagramScene (GraphicsView) Example not working"
The correct title would be "QVariant doesn't correct store a QGraphicsScene object."
-rw-r--r-- | PySide/QtCore/qvariant_conversions.h | 5 | ||||
-rw-r--r-- | tests/QtGui/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/QtGui/qvariant_test.py | 23 |
3 files changed, 25 insertions, 4 deletions
diff --git a/PySide/QtCore/qvariant_conversions.h b/PySide/QtCore/qvariant_conversions.h index 06a8368cd..fc2dca55c 100644 --- a/PySide/QtCore/qvariant_conversions.h +++ b/PySide/QtCore/qvariant_conversions.h @@ -47,9 +47,6 @@ struct Converter<QVariant> return convertToVariantMap(pyObj); } else if (PySequence_Check(pyObj)) { return convertToVariantList(pyObj); - } else if (!isShibokenType(pyObj) || isUserType(pyObj)) { - // QVariant(User class) - return QVariant::fromValue<PySide::PyObjectWrapper>(pyObj); } else { // a class supported by QVariant? if (Shiboken::isShibokenType(pyObj)) { @@ -60,7 +57,7 @@ struct Converter<QVariant> void** data = reinterpret_cast<SbkBaseWrapper*>(pyObj)->cptr; if (typeName[strlen(typeName)-1] == '*') return QVariant(typeCode, data); - else + else if (!isUserType(pyObj)) // User types inherited from Value types *should* not be converted. return QVariant(typeCode, data[0]); } } diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 9b928acb8..a26c1f615 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -61,6 +61,7 @@ PYSIDE_TEST(qtextedit_test.py) PYSIDE_TEST(qtextedit_signal_test.py) PYSIDE_TEST(qtoolbar_test.py) PYSIDE_TEST(qtoolbox_test.py) +PYSIDE_TEST(qvariant_test.py) PYSIDE_TEST(qwidget_setlayout_test.py) PYSIDE_TEST(qwidget_test.py) PYSIDE_TEST(reference_count_test.py) diff --git a/tests/QtGui/qvariant_test.py b/tests/QtGui/qvariant_test.py new file mode 100644 index 000000000..faa755a18 --- /dev/null +++ b/tests/QtGui/qvariant_test.py @@ -0,0 +1,23 @@ + +import unittest +from PySide.QtCore import * +from PySide.QtGui import * + +class MyDiagram(QGraphicsScene): + pass + +class MyItem(QGraphicsRectItem): + def itemChange(self, change, value): + return value; + +class QGraphicsSceneOnQVariantTest(unittest.TestCase): + """Test storage ot QGraphicsScene into QVariants""" + def testIt(self): + app = QApplication([]) + s = MyDiagram() + i = MyItem() + s.addItem(i) + self.assertEqual(len(s.items()), 1) + +if __name__ == '__main__': + unittest.main() |