summaryrefslogtreecommitdiffstats
path: root/perl-install/ugtk2.pm
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-04-03 15:50:36 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-04-03 15:50:36 +0000
commit00800baae739e4aaeabd33b69026a76a360e094b (patch)
tree52c9b85f7e929cd42987037fd36d67154654ef25 /perl-install/ugtk2.pm
parent1c37b3c7aafa49a79d0308133023153542274746 (diff)
downloaddrakx-00800baae739e4aaeabd33b69026a76a360e094b.tar
drakx-00800baae739e4aaeabd33b69026a76a360e094b.tar.gz
drakx-00800baae739e4aaeabd33b69026a76a360e094b.tar.bz2
drakx-00800baae739e4aaeabd33b69026a76a360e094b.tar.xz
drakx-00800baae739e4aaeabd33b69026a76a360e094b.zip
fix #3633 (cursor at the end of TextView after gtktext_insert)
remove a few memory leaks
Diffstat (limited to 'perl-install/ugtk2.pm')
-rw-r--r--perl-install/ugtk2.pm15
1 files changed, 11 insertions, 4 deletions
diff --git a/perl-install/ugtk2.pm b/perl-install/ugtk2.pm
index d62d2d4e3..67f9fb774 100644
--- a/perl-install/ugtk2.pm
+++ b/perl-install/ugtk2.pm
@@ -539,21 +539,28 @@ sub gtktext_append { gtktext_insert(@_, { 'append' => 1 }) }
# ... ]);
sub gtktext_insert {
my ($textview, $t, $opts) = @_;
+ my $buffer = $textview->get_buffer;
if (ref($t) eq 'ARRAY') {
- my $buffer = $textview->get_buffer;
$opts->{append} or $buffer->set_text('', -1);
foreach my $token (@$t) {
+ my ($iter1, $iter2);
my $c = $buffer->get_char_count;
- $buffer->insert($buffer->get_end_iter, $token->[0], -1);
+ $buffer->insert($iter1 = $buffer->get_end_iter, $token->[0], -1);
+ $iter1->free;
if ($token->[1]) {
my $tag = $buffer->create_tag(undef);
$tag->set(%{$token->[1]});
- $buffer->apply_tag($tag, $buffer->get_iter_at_offset($c), $buffer->get_end_iter);
+ $buffer->apply_tag($tag, $iter1 = $buffer->get_iter_at_offset($c), $iter2 = $buffer->get_end_iter);
+ $iter1->free; $iter2->free;
}
}
} else {
- $textview->get_buffer->set_text($t, -1);
+ $buffer->set_text($t, -1);
}
+ #- the following lines are needed to move the cursor mark to the beginning, so that if the
+ #- textview has a scrollbar, it won't scroll to the bottom when focusing (#3633)
+ $buffer->move_mark_by_name('selection_bound', my $beg = $buffer->get_start_iter); $beg->free;
+ $buffer->move_mark_by_name('insert', my $end = $buffer->get_start_iter); $end->free;
$textview->set_wrap_mode($opts->{wrap_mode} || 'word');
$textview->set_editable($opts->{editable} || 0);
$textview->set_cursor_visible($opts->{visible} || 0);