Re: Problem with global destruction



muppet kirjoitti:
Ari Jolma wrote:
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
Gtk2::ScrolledWindow):

$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.

Couldn't do that, the signal seems to connect (it returns an integer) but does not get called (I tried signals "destroy" and "destroy_event"). However, I can call the do_destroy (below) from the close subroutine of the main window. But that does seem to help :(

Ari

 # INIT_INSTANCE
   # 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};





--
Prof. Ari Jolma
Geoinformaatio- ja paikannustekniikka
Geoinformation and positioning technology
Teknillinen Korkeakoulu / Helsinki University of Technology
POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma




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