From c8970b29d76415d41fa383cbe5eb77eefb191fa1 Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Mon, 7 Jan 2019 12:46:13 +0100 Subject: [reg] Remove createIndex method that uses PyObject* Even though we have support for Void*, having to import it as an additional class to be able to call a separate function, is adding too much complexity so something that should be easy to do, like creating an index for an itemmodel. The regression is a change that replaced the way of doing: QAbstractItemModel.createIndex(0, 0, PyObject*) to QAbstractItemModel.createIndex(0, 0, VoidPtr(PyObject*)) which is not really intuitive, and is generating other issues. Included modification in the registries too. Change-Id: Ie6112c6baeb4fc3b22fc78e7edeb66aa4a17c22b Fixes: PYSIDE-883 Reviewed-by: Christian Tismer Reviewed-by: Qt CI Bot --- .../pyside2/tests/QtCore/qmodelindex_internalpointer_test.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'sources/pyside2/tests/QtCore') diff --git a/sources/pyside2/tests/QtCore/qmodelindex_internalpointer_test.py b/sources/pyside2/tests/QtCore/qmodelindex_internalpointer_test.py index a67bb380a..770600ea3 100644 --- a/sources/pyside2/tests/QtCore/qmodelindex_internalpointer_test.py +++ b/sources/pyside2/tests/QtCore/qmodelindex_internalpointer_test.py @@ -33,7 +33,6 @@ import sys import unittest from PySide2.QtCore import * -from PySide2.support import VoidPtr class MyModel (QAbstractListModel): pass @@ -51,21 +50,20 @@ class TestQModelIndexInternalPointer(unittest.TestCase): def testInternalPointer(self): #Test QAbstractListModel.createIndex and - #QModelIndex.internalPointer + #QModelIndex.internalPointer with regular Python objects obj = QObject() - obj_ptr = VoidPtr(obj) - idx = self.model.createIndex(0, 0, obj) + idx = self.model.createIndex(0, 0, "Hello") i = idx.internalPointer() - self.assertEqual(int(obj_ptr), int(i)) + self.assertEqual(i, "Hello") def testReferenceCounting(self): #Test reference counting when retrieving data with #QModelIndex.internalPointer - o = QObject() + o = [1, 2, 3] o_refcnt = sys.getrefcount(o) idx = self.model.createIndex(0, 0, o) ptr = idx.internalPointer() - self.assertEqual(sys.getrefcount(o), o_refcnt) + self.assertEqual(sys.getrefcount(o), o_refcnt + 1) def testIndexForDefaultDataArg(self): -- cgit v1.2.3