Fix Property GC tracking for Python 3.11
authorChristian Tismer <tismer@stackless.com>
Sun, 11 Sep 2022 09:19:20 +0000 (11:19 +0200)
committerDmitry Shachnev <mitya57@debian.org>
Sun, 1 Oct 2023 20:43:44 +0000 (21:43 +0100)
The GC was not untracked when PySide Property was deleted.
This was found by the new deeper error tracking in debug Python 3.11 .

Fixes: PYSIDE-1960
Change-Id: I5ecdfb88529c22a44575ca9460d6753b1e389079
Pick-to: 6.2 6.3 5.15
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit ace680f4c5fc8564df9daaa41bf8779c9fffa671)

Gbp-Pq: Name Fix-Property-GC-tracking-for-Python-3.11.patch

sources/pyside2/libpyside/pysideproperty.cpp

index 1a3a4115b680a4f85c0738efcc128a201f60f29b..86909d3bc25b3e4101c0bf2aa2354bdef4d2880a 100644 (file)
@@ -104,6 +104,7 @@ static PyType_Slot PySidePropertyType_slots[] = {
     {Py_tp_init, (void *)qpropertyTpInit},
     {Py_tp_new, (void *)qpropertyTpNew},
     {Py_tp_getset, PySidePropertyType_getset},
+    {Py_tp_del, reinterpret_cast<void *>(PyObject_GC_Del)},
     {0, 0}
 };
 // Dotted modulename is crucial for SbkType_FromSpec to work. Is this name right?
@@ -249,6 +250,7 @@ static void qpropertyDeAlloc(PyObject *self)
         // This was not needed before Python 3.8 (Python issue 35810)
         Py_DECREF(Py_TYPE(self));
     }
+    PyObject_GC_UnTrack(self);
     Py_TYPE(self)->tp_free(self);
 }