Breaking reference cycles ( continued from ages ago )



Hi all.

Carrying on from my previous post on managing windows in an OO way and not being able to destroy things ...

I've made an array of all objects & signal handler IDs that I get when I connect to various signals, in both projects Gtk2::Ex::DBI and Gtk2::Ex::Datasheet::DBI.

When I want to destroy an instance of the above, I do:

sub destroy_signal_handlers {
my $self = shift; foreach my $set ( @{$self->{objects_and_signals}} ) {
       $$set[0]->signal_handler_disconnect( $$set[1] );
   }
return TRUE; }

... where the 1st element in the array is the object, and the 2nd element is the signal handler ID. In Gtk2::Ex::DBI, this is sufficient ... ie if I run the above sub, and then run the sub:

sub destroy_self {
undef $_[0]; }

the object is destroyed successfully. Cool :)

However in Gtk2::Ex::Datasheet::DBI, this doesn't work. This could very well be because I'm using some custom cell renderers that set up their own signal handlers, eg:

$editable -> signal_connect(key_press_event => sub { ... some stuff ...});

Do I have to clean this stuff up as well? The cell renderers aren't set up in an OO way ( ie they can't see $self that the rest of Gtk2::Ex::Datasheet::DBI sees ). This will make my above approach of stuffing them in an array and disconnecting them later more complicated.

--
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak nusconsulting com au
website: http://www.nusconsulting.com.au



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