[pve-devel] [PATCH ha-manager 01/10] Simulator: do not use cursor position to insert log

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Dec 21 16:44:38 CET 2016


While the cursor is set invisible it can be still set by clicking
somewhere in the log window. As we uset insert_at_cursor() to append
text, asuming that the cursor is always at the end, this results in
an erroneous behavior where new log text get inserted at arbitrary
positions.
Use get_end_iter() to get the real end of the text buffer instead.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/HA/Sim/RTHardware.pm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/PVE/HA/Sim/RTHardware.pm b/src/PVE/HA/Sim/RTHardware.pm
index 606d3ef..02c0589 100644
--- a/src/PVE/HA/Sim/RTHardware.pm
+++ b/src/PVE/HA/Sim/RTHardware.pm
@@ -278,11 +278,13 @@ sub append_text {
     my $logview = $self->{gui}->{text_view} || die "GUI not ready";
     my $textbuf = $logview->get_buffer();
 
-    $textbuf->insert_at_cursor($text, -1);
+    my $end_iter = $textbuf->get_end_iter();
+    $textbuf->insert($end_iter, $text, -1);
+
     my $lines = $textbuf->get_line_count();
 
     my $history = 102;
-    
+
     if ($lines > $history) {
 	my $start = $textbuf->get_iter_at_line(0);
 	my $end =  $textbuf->get_iter_at_line($lines - $history);
-- 
2.1.4





More information about the pve-devel mailing list