Re: Problem with global destruction

Ari Jolma wrote:
I wrote:
class is created and used. I've defined two new signal types for the object.

I tried commenting out every line of code which has something to do with
signals and it turns out that if I connect the size_allocate signal to a
function (this is in sub INIT_INSTANCE of the subclass of

$self->{image}->signal_connect(size_allocate => \&size_allocate, $self);

the problem appears.

At first blush, it sounds like you have created a reference leak.  (This is
far from definitive, but that's what it sounds like.)

Try overriding the destroy signal (NOT the DESTROY method, but the "destroy"
signal!!) on your ScrolledWindow subclass, and in there, disconnect the signal
and destroy the child.

   # keep the handler id so we can disconnect it later
   $self->{image_allocate_signal} =
        $self->{image}->signal_connect(size_allocate => \&size_allocate, $self);

 # do_destroy
   # disconnect the handler added in INIT_INSTANCE to break the ref cycle
   $self->{image}->signal_handler_disconnect ($self->{image_allocate_signal});
   # chain up, so that the rest of the destruction happens properly
   $self->signal_chain_from_overridden (@_);
   # release our own reference (may not be strictly necessary)
   delete $self->{image};

muppet <scott at asofyet dot org>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]