Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2023-02-01 18:46:11 +0100
committerChristian Tismer <tismer@stackless.com>2023-02-07 15:17:16 +0100
commit08ec50ff3b569e2062285ee633f5c7e548c67545 (patch)
tree7b8dfc5e578e9b062492aa9cb909cdd49441eb97 /sources/pyside6/libpyside/pysidesignal.cpp
parentffc97efcd23fb6ae72ea2d864a1d82c16646c543 (diff)
signal: Finally clean up all leaks after complete understanding
The PYSIDE-79 bug was never understood, completely. After getting much more clarity through the work on PYSIDE-2201, the real problem could be found: It turned out that the implementation of descriptors was incomplete. Instead of respecting an already cached instance, it created a new one, all the time, resulting in a serious leak! This became visible by deep inspection of the control flow with VS-Code. After the interaction of PyObject_GetAttr, getHiddenDataFromQObject and signalDescrGet became transparent, the function was completed and the issue finally solved. Fixes: PYSIDE-79 Task-number: PYSIDE-68 Task-number: PYSIDE-2201 Change-Id: Ifd6098b1ce43d9bf51350218deb031bbf9ccb97a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/libpyside/pysidesignal.cpp')
-rw-r--r--sources/pyside6/libpyside/pysidesignal.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/sources/pyside6/libpyside/pysidesignal.cpp b/sources/pyside6/libpyside/pysidesignal.cpp
index cdc3042c0..f7c9073c2 100644
--- a/sources/pyside6/libpyside/pysidesignal.cpp
+++ b/sources/pyside6/libpyside/pysidesignal.cpp
@@ -683,8 +683,18 @@ static PyObject *signalDescrGet(PyObject *self, PyObject *obj, PyObject * /*type
Py_INCREF(self);
return self;
}
+
+ // PYSIDE-68-bis: It is important to respect the already cached instance.
Shiboken::AutoDecRef name(Py_BuildValue("s", signal->data->signalName.data()));
- return reinterpret_cast<PyObject *>(PySide::Signal::initialize(signal, name, obj));
+ auto *dict = SbkObject_GetDict_NoRef(obj);
+ auto *inst = PyDict_GetItem(dict, name);
+ if (inst) {
+ Py_INCREF(inst);
+ return inst;
+ }
+ inst = reinterpret_cast<PyObject *>(PySide::Signal::initialize(signal, name, obj));
+ PyObject_SetAttr(obj, name, inst);
+ return inst;
}
static PyObject *signalCall(PyObject *self, PyObject *args, PyObject *kw)
@@ -1032,10 +1042,9 @@ PySideSignalInstance *newObjectFromMethod(PyObject *source, const QList<QMetaMet
item->deleted = false;
PySideSignalInstancePrivate *selfPvt = item->d;
selfPvt->source = source;
- Py_INCREF(selfPvt->source); // PYSIDE-79: an INCREF is missing.
QByteArray cppName(m.methodSignature());
cppName.truncate(cppName.indexOf('('));
- // separe SignalName
+ // separate SignalName
selfPvt->signalName = cppName;
selfPvt->signature = m.methodSignature();
selfPvt->attributes = m.attributes();