aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6')
-rw-r--r--sources/pyside6/libpyside/globalreceiverv2.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/sources/pyside6/libpyside/globalreceiverv2.cpp b/sources/pyside6/libpyside/globalreceiverv2.cpp
index 72197fe51..6d6ae3abf 100644
--- a/sources/pyside6/libpyside/globalreceiverv2.cpp
+++ b/sources/pyside6/libpyside/globalreceiverv2.cpp
@@ -105,14 +105,14 @@ DynamicSlotDataV2::DynamicSlotDataV2(PyObject *callback, GlobalReceiverV2 *paren
//monitor class from method lifetime
m_weakRef = WeakRef::create(m_pythonSelf, DynamicSlotDataV2::onCallbackDestroyed, this);
- m_hash = QByteArray::number((qlonglong)PyObject_Hash(m_callback))
- + QByteArray::number((qlonglong)PyObject_Hash(m_pythonSelf));
-
+ // PYSIDE-1422: Avoid hash on self which might be unhashable.
+ m_hash = QByteArray::number(static_cast<qlonglong>(PyObject_Hash(m_callback)))
+ + QByteArray::number(reinterpret_cast<qlonglong>(m_pythonSelf));
} else {
m_callback = callback;
Py_INCREF(m_callback);
- m_hash = QByteArray::number((qlonglong)PyObject_Hash(m_callback));
+ m_hash = QByteArray::number(static_cast<qlonglong>(PyObject_Hash(m_callback)));
}
}
@@ -125,10 +125,11 @@ QByteArray DynamicSlotDataV2::hash(PyObject *callback)
{
Shiboken::GilState gil;
if (PyMethod_Check(callback)) {
- return QByteArray::number((qlonglong)PyObject_Hash(PyMethod_GET_FUNCTION(callback)))
- + QByteArray::number((qlonglong)PyObject_Hash(PyMethod_GET_SELF(callback)));
+ // PYSIDE-1422: Avoid hash on self which might be unhashable.
+ return QByteArray::number(static_cast<qlonglong>(PyObject_Hash(PyMethod_GET_FUNCTION(callback))))
+ + QByteArray::number(reinterpret_cast<qlonglong>(PyMethod_GET_SELF(callback)));
}
- return QByteArray::number(qlonglong(PyObject_Hash(callback)));
+ return QByteArray::number(static_cast<qlonglong>(PyObject_Hash(callback)));
}
PyObject *DynamicSlotDataV2::callback()