[PyQt] Inconsistent gc behavior for reference cycles introduced by connections to lambda

Phil Thompson phil at riverbankcomputing.com
Tue Mar 27 18:40:36 BST 2018


On 26 Mar 2018, at 12:57 pm, Ales Erjavec <ales.erjavec324 at gmail.com> wrote:
> 
> Hi,
> 
> There appears to be inconsistency in traversing and GC-ing of some QObject
> derived classes.
> 
> For instance connecting `QObject.objectNameChanged` signal to a lambda
> (capturing
> the the QObject instance), lists that lambda in the `gc.get_referents`
> (assuming as
> implemented by %GCTraverseCode in qobject.sip). Deleting a reference
> for the object
> and invoking `gc.collect` successfully disposes of the ref cycle.
> 
> However for QAbstractItemModel subclasses (QStringListModel,
> QStandardListModel, ...)
> this is not the case. They do no list the lambda slots in
> `gc.get_referents` and leak the
> reference cycle.

Should be fixed in tonight's SIP snapshot.

Thanks (especially for the good test script),
Phil


More information about the PyQt mailing list