[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sylpheed
Subject:    [sylpheed:23867] Re: Fixes to compose.c
From:       Alfons Hoogervorst <alfons () proteus ! demon ! nl>
Date:       2005-01-20 11:41:22
Message-ID: 20050120124122.03bca8c9.alfons () proteus ! demon ! nl
[Download RAW message or body]

Lo,

On Thu, 20 Jan 2005 01:18:31 +0100 Alfons Hoogervorst wrote: 

Claws source is different here too.

For the same reason mentioned in the previous messages, the signature 
insertion point iterator is invalidated after text buffer operations. This 
results in random truncation of signatures.

The patch fixes this by keeping track of the insertion point using a text 
mark.

Bye.

-- 
Ecuación algebraico sin solución posible,
a menos de poseer profundos conocimientos
en matemática - Revueltas (Ocho Por Radio)


["signature-truncation.compose.patch" (text/plain)]

--- sylpheed-old/trunk/src/compose.c	2005-01-20 01:13:55.000000000 +0100
+++ sylpheed-new/trunk/src/compose.c	2005-01-20 12:27:04.000000000 +0100
@@ -1499,7 +1499,7 @@
 {
 	GtkTextView *text = GTK_TEXT_VIEW(compose->text);
 	GtkTextBuffer *buffer;
-	GtkTextMark *mark;
+	GtkTextMark *mark, *sig_ins_mark;
 	GtkTextIter iter;
 	gint cur_pos;
 
@@ -1508,10 +1508,13 @@
 	buffer = gtk_text_view_get_buffer(text);
 	mark = gtk_text_buffer_get_insert(buffer);
 	gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
+	sig_ins_mark = gtk_text_buffer_create_mark(buffer, NULL, &iter, FALSE);
 	cur_pos = gtk_text_iter_get_offset(&iter);
 
-	if (replace)
+	if (replace) {
 		gtk_text_buffer_get_end_iter(buffer, &iter);
+		gtk_text_buffer_move_mark(buffer, sig_ins_mark, &iter);
+	}		
 
 	if (replace && compose->sig_str) {
 		GtkTextIter first_iter, start_iter, end_iter;
@@ -1530,14 +1533,19 @@
 		if (found) {
 			gtk_text_buffer_delete(buffer, &start_iter, &end_iter);
 			iter = start_iter;
+			gtk_text_buffer_move_mark(buffer, sig_ins_mark, &iter);
 		}
 	}
 
 	g_free(compose->sig_str);
 	compose->sig_str = compose_get_signature_str(compose);
 	if (compose->sig_str) {
-		if (!replace)
+		gtk_text_buffer_get_iter_at_mark(buffer, &iter, sig_ins_mark); 
+		if (!replace) {
 			gtk_text_buffer_insert(buffer, &iter, "\n\n", 2);
+			gtk_text_buffer_get_iter_at_mark(buffer, &iter, sig_ins_mark);
+		}	
+			
 		gtk_text_buffer_insert(buffer, &iter, compose->sig_str, -1);
 	} else
 		compose->sig_str = g_strdup("");
@@ -1547,6 +1555,8 @@
 
 	gtk_text_buffer_get_iter_at_offset(buffer, &iter, cur_pos);
 	gtk_text_buffer_move_mark(buffer, mark, &iter);
+
+	gtk_text_buffer_delete_mark(buffer, sig_ins_mark);
 }
 
 static gchar *compose_get_signature_str(Compose *compose)




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic