Weakref breaks lambda callbacks

Bug #403901 reported by Adam Olsen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Exaile
Won't Fix
Critical
reacocard

Bug Description

Weakref breaks lambda callbacks, for instance:

event.add_callback(lambda *e: self.update_track_counts(), 'tracks_added', self.queue)

That lambda function will never be called. This happens regardless of the new gobject.idle_add changes - I tried it in an older revision pre-gobject.

I have the suspicion that it doesn't work for inner functions either, for example:

def _connect_events(self):
        def queue_playlist_draw(*e):
            self.get_selected_playlist().list.queue_draw()

        event.add_callback(queue_playlist_draw, 'stop_track', self.queue)

queue_playlist_draw never gets called. I cannot tell if this is due to the weakref or the idle_add stuff.

Adam Olsen (arolsen)
tags: added: add event idle weakref
Changed in exaile:
status: New → Confirmed
Revision history for this message
reacocard (reacocard) wrote :

This is by the nature of weakrefs - if there is no other reference to the callback, it disappears. Thus you can only use a lambda if it is assigned to a variable or some other reference is kept to it outside of event.

Changed in exaile:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.