diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-01-16 10:14:21 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-01-16 14:38:30 +0100 |
commit | b4144265b820a852ae7670edbee529b7a42818b1 (patch) | |
tree | 96acb4c201084feb307bee2d6e1276510b5cf361 /sources/shiboken6/tests | |
parent | 31e7f5325ec852ddf46ecff978a3140406154274 (diff) |
Shiboken.wrapInstance(): Return existing instance (preserve ids)
Before calling newObject(), check whether a wrapper already
exists and return that. newObject() actually also has checks for
this, but it then invalidates the existing wrapper.
Task-number: PYSIDE-31
Change-Id: Ifb8c33ebb6b4e2e976c207dd324fb8df29f043b1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/tests')
-rw-r--r-- | sources/shiboken6/tests/shibokenmodule/module_test.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/shibokenmodule/module_test.py b/sources/shiboken6/tests/shibokenmodule/module_test.py index a1f955752..9f9f8f5a4 100644 --- a/sources/shiboken6/tests/shibokenmodule/module_test.py +++ b/sources/shiboken6/tests/shibokenmodule/module_test.py @@ -45,6 +45,16 @@ class TestShiboken(unittest.TestCase): self.assertTrue(Shiboken.createdByPython(bb)) bb.disposeObjectType(bb.keepObjectType(obj)) + def testWrapInstancePreserveId(self): + """PYSIDE-31: Verify that wrapInstance() returns the existing wrapper + even if a base class type is specified.""" + v = ObjectView() # inherits ObjectType + addresses = Shiboken.getCppPointer(v) + self.assertTrue(addresses) + address = addresses[0] + wrapped = Shiboken.wrapInstance(address, ObjectType) + self.assertEqual(id(wrapped), id(v)) + def testIsOwnedByPython(self): obj = ObjectType() self.assertTrue(Shiboken.ownedByPython(obj)) |