diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2003-02-10 13:44:57 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2003-02-10 13:44:57 +0000 |
commit | 65e1d3f778faaff8a1755251118ae9e00ecd0d82 (patch) | |
tree | 0204e6d65943fcb412c89705ea1a138d0ebb8f4a /perl-install | |
parent | dc22ec762d9f5a293e8b7c036add8d5dc41922e3 (diff) | |
download | drakx-65e1d3f778faaff8a1755251118ae9e00ecd0d82.tar drakx-65e1d3f778faaff8a1755251118ae9e00ecd0d82.tar.gz drakx-65e1d3f778faaff8a1755251118ae9e00ecd0d82.tar.bz2 drakx-65e1d3f778faaff8a1755251118ae9e00ecd0d82.tar.xz drakx-65e1d3f778faaff8a1755251118ae9e00ecd0d82.zip |
when displaying images in treeview, unref pixbufs right after their use so that we try to save some memory
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/interactive/gtk.pm | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/perl-install/interactive/gtk.pm b/perl-install/interactive/gtk.pm index a923261a1..a7c7968c4 100644 --- a/perl-install/interactive/gtk.pm +++ b/perl-install/interactive/gtk.pm @@ -162,17 +162,19 @@ sub create_treeview_tree { $tree->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 2)); $tree->set_headers_visible(0); - my @to_unref; - $tree->signal_connect(destroy => sub { $_->unref foreach @to_unref }); - my $build_value = sub { - if (exists $e->{image2f}) { + my ($build_value, $clean_image); + if (exists $e->{image2f}) { + my $to_unref; + $build_value = sub { my ($text, $image) = $e->{image2f}->($_[0]); [ $text ? (0 => $text) : (), - $image ? (1 => do { push @to_unref, my $img = gtkcreate_pixbuf($image); $img }) : () ]; - } else { - [ 0 => $_[0] ]; - } - }; + $image ? (1 => my $to_unref = gtkcreate_pixbuf($image)) : () ]; + }; + $clean_image = sub { $to_unref and $to_unref->unref }; + } else { + $build_value = sub { [ 0 => $_[0] ] }; + $clean_image = sub {}; + } my (%wtree, %wleaves, $size, $selected_via_click); my $parent; $parent = sub { @@ -181,6 +183,7 @@ sub create_treeview_tree { foreach (split $sep, $_[0]) { $wtree{"$s$_$e->{separator}"} ||= $tree_model->append_set($s ? $parent->($s) : undef, $build_value->($_)); + $clean_image->(); $size++ if !$s; $s .= "$_$e->{separator}"; } @@ -192,6 +195,7 @@ sub create_treeview_tree { mapn { my ($root, $leaf) = $_[0] =~ /(.*)$sep(.+)/ ? ($1, $2) : ('', $_[0]); my $iter = $tree_model->append_set($parent->($root), $build_value->($leaf)); + $clean_image->(); my $pathstr = $tree_model->get_path_str($iter); $iter->free; $precomp{$pathstr} = { value => $leaf, fullvalue => $_[0], listvalue => $_[1] }; |