aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/pyside6/libpyside/signalmanager.cpp4
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp6
-rw-r--r--sources/shiboken6/libshiboken/basewrapper.cpp12
-rw-r--r--sources/shiboken6/libshiboken/basewrapper.h2
-rw-r--r--sources/shiboken6/libshiboken/bindingmanager.cpp2
5 files changed, 11 insertions, 15 deletions
diff --git a/sources/pyside6/libpyside/signalmanager.cpp b/sources/pyside6/libpyside/signalmanager.cpp
index 05769f213..bf9a5a4ad 100644
--- a/sources/pyside6/libpyside/signalmanager.cpp
+++ b/sources/pyside6/libpyside/signalmanager.cpp
@@ -526,7 +526,7 @@ int SignalManager::registerMetaMethodGetIndex(QObject *source, const char *signa
return -1;
}
auto *pySelf = reinterpret_cast<PyObject *>(self);
- auto *dict = SbkObject_GetDict(pySelf);
+ auto *dict = SbkObject_GetDict_NoRef(pySelf);
MetaObjectBuilder *dmo = metaBuilderFromDict(dict);
// Create a instance meta object
@@ -555,7 +555,7 @@ const QMetaObject *SignalManager::retrieveMetaObject(PyObject *self)
// m_dirty flag is set.
Q_ASSERT(self);
- auto *ob_dict = SbkObject_GetDict(self);
+ auto *ob_dict = SbkObject_GetDict_NoRef(self);
MetaObjectBuilder *builder = metaBuilderFromDict(ob_dict);
if (!builder)
builder = &(retrieveTypeUserData(self)->mo);
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index f93024d55..e7f0f5351 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -6084,8 +6084,8 @@ void CppGenerator::writeGetattroFunction(TextStream &s, AttroCheck attroCheck,
if (attroCheck.testFlag(AttroCheckFlag::GetattroOverloads)) {
s << "// Search the method in the instance dict\n"
- << "auto ob_dict = SbkObject_GetDict(self);\n";
- s << "if (auto meth = PyDict_GetItem(ob_dict, name)) {\n";
+ << "auto *ob_dict = SbkObject_GetDict_NoRef(self);\n";
+ s << "if (auto *meth = PyDict_GetItem(ob_dict, name)) {\n";
{
Indentation indent(s);
s << "Py_INCREF(meth);\n"
@@ -6098,7 +6098,7 @@ void CppGenerator::writeGetattroFunction(TextStream &s, AttroCheck attroCheck,
Indentation indent(s);
// PYSIDE-772: Perform optimized name mangling.
s << "Shiboken::AutoDecRef tmp(_Pep_PrivateMangle(self, name));\n"
- << "if (auto meth = PyDict_GetItem(Py_TYPE(self)->tp_dict, tmp)) {\n";
+ << "if (auto *meth = PyDict_GetItem(Py_TYPE(self)->tp_dict, tmp)) {\n";
{
Indentation indent(s);
// PYSIDE-1523: PyFunction_Check is not accepting compiled functions.
diff --git a/sources/shiboken6/libshiboken/basewrapper.cpp b/sources/shiboken6/libshiboken/basewrapper.cpp
index 7a615b06b..eb8069525 100644
--- a/sources/shiboken6/libshiboken/basewrapper.cpp
+++ b/sources/shiboken6/libshiboken/basewrapper.cpp
@@ -104,7 +104,7 @@ void setDestroyQApplication(DestroyQAppHook func)
}
// PYSIDE-535: Use the C API in PyPy instead of `op->ob_dict`, directly
-LIBSHIBOKEN_API PyObject *SbkObject_GetDict(PyObject *op)
+LIBSHIBOKEN_API PyObject *SbkObject_GetDict_NoRef(PyObject *op)
{
#ifdef PYPY_VERSION
auto *ret = PyObject_GenericGetDict(op, nullptr);
@@ -187,13 +187,9 @@ PyTypeObject *SbkObjectType_TypeF(void)
static PyObject *SbkObjectGetDict(PyObject *pObj, void *)
{
- auto *obj = reinterpret_cast<SbkObject *>(pObj);
- if (!obj->ob_dict)
- obj->ob_dict = PyDict_New();
- if (!obj->ob_dict)
- return nullptr;
- Py_INCREF(obj->ob_dict);
- return obj->ob_dict;
+ auto ret = SbkObject_GetDict_NoRef(pObj);
+ Py_XINCREF(ret);
+ return ret;
}
static PyGetSetDef SbkObjectGetSetList[] = {
diff --git a/sources/shiboken6/libshiboken/basewrapper.h b/sources/shiboken6/libshiboken/basewrapper.h
index 27441ad17..85556ec61 100644
--- a/sources/shiboken6/libshiboken/basewrapper.h
+++ b/sources/shiboken6/libshiboken/basewrapper.h
@@ -113,7 +113,7 @@ typedef void(*DestroyQAppHook)();
LIBSHIBOKEN_API void setDestroyQApplication(DestroyQAppHook func);
/// PYSIDE-535: Use the C API in PyPy instead of `op->ob_dict`, directly (borrowed ref)
-LIBSHIBOKEN_API PyObject *SbkObject_GetDict(PyObject *op);
+LIBSHIBOKEN_API PyObject *SbkObject_GetDict_NoRef(PyObject *op);
extern LIBSHIBOKEN_API PyTypeObject *SbkObjectType_TypeF(void);
extern LIBSHIBOKEN_API PyTypeObject *SbkObject_TypeF(void);
diff --git a/sources/shiboken6/libshiboken/bindingmanager.cpp b/sources/shiboken6/libshiboken/bindingmanager.cpp
index 020ff3c9b..6fa625907 100644
--- a/sources/shiboken6/libshiboken/bindingmanager.cpp
+++ b/sources/shiboken6/libshiboken/bindingmanager.cpp
@@ -304,7 +304,7 @@ PyObject *BindingManager::getOverride(const void *cptr,
}
auto *obWrapper = reinterpret_cast<PyObject *>(wrapper);
- auto *wrapper_dict = SbkObject_GetDict(obWrapper);
+ auto *wrapper_dict = SbkObject_GetDict_NoRef(obWrapper);
if (PyObject *method = PyDict_GetItem(wrapper_dict, pyMethodName)) {
Py_INCREF(method);
return method;