aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken
diff options
context:
space:
mode:
authorNathan Smith <nathanjsmith@gmail.com>2012-07-03 17:35:27 -0500
committerMarcelo Lira <marcelo.lira@openbossa.org>2012-07-04 20:22:03 +0200
commite1a91dd721c17727bea41b591336d1cacca6dea4 (patch)
treef9987e7235b2a8d1375b0b2b6d0e7a1a170282be /libshiboken
parent7e5c76981d6bcb04b72a407a6bc4076170ee414e (diff)
Fix and test case for bug PYSIDE-72.
The address of the PyObject is used directly as the hash rather than a member of that object. This avoids segfaults when the C++ object has been deleted, rendering the child pointers NULL. Removed a test case verifying that hash(QObject()) != hash(QObject()) because they in fact can be equal. The first QObject dies and is reaped before the second QObject is created, meaning that the second QObject may be allocated at the same address as the first QObject, giving them both the same address. If a reference is held to the first object, though, then they will get different hash values. Change-Id: I116463f88b837726a98720bae36770d53b13f4ee Reviewed-by: Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'libshiboken')
-rw-r--r--libshiboken/basewrapper.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp
index 0b7617e5c..096f2c580 100644
--- a/libshiboken/basewrapper.cpp
+++ b/libshiboken/basewrapper.cpp
@@ -751,7 +751,7 @@ bool isUserType(PyObject* pyObj)
Py_hash_t hash(PyObject* pyObj)
{
assert(Shiboken::Object::checkType(pyObj));
- return reinterpret_cast<Py_hash_t>(reinterpret_cast<SbkObject*>(pyObj)->d->cptr[0]);
+ return reinterpret_cast<Py_hash_t>(pyObj);
}
static void setSequenceOwnership(PyObject* pyObj, bool owner)