[gtkhtml] Bug #681495 - Cannot insert a link before another one



commit 4099ac353d3e0c1be4cde4f85385a0f5441ccfec
Author: Milan Crha <mcrha redhat com>
Date:   Fri Aug 24 15:19:15 2012 +0200

    Bug #681495 - Cannot insert a link before another one

 gtkhtml/htmltext.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/gtkhtml/htmltext.c b/gtkhtml/htmltext.c
index 7a06809..35cf56d 100644
--- a/gtkhtml/htmltext.c
+++ b/gtkhtml/htmltext.c
@@ -3600,18 +3600,14 @@ html_text_add_link_full (HTMLText *text,
 					html_link_free (new_link);
 					new_link = NULL;
 				} else {
-					l = g_slist_prepend (l, new_link);
-					if (prev)
-						prev->next = l;
-					else
-						text->links = l;
+					text->links = g_slist_insert_before (text->links, l, new_link);
 					link = new_link;
 					new_link = NULL;
 				}
 				if (plink && html_link_equal (plink, link) && plink->start_offset == link->end_offset) {
 					plink->start_offset = link->start_offset;
 					plink->start_index = link->start_index;
-					prev->next = g_slist_remove (prev->next, link);
+					text->links = g_slist_remove (text->links, link);
 					html_link_free (link);
 					link = plink;
 				}
@@ -3620,8 +3616,13 @@ html_text_add_link_full (HTMLText *text,
 			}
 		}
 
-		if (new_link && prev)
-			prev->next = g_slist_prepend (NULL, new_link);
+		if (new_link && prev) {
+			if (prev->next)
+				text->links = g_slist_insert_before (text->links, prev->next, new_link);
+			else
+				text->links = g_slist_append (text->links, new_link);
+		} else if (new_link)
+			text->links = g_slist_prepend (text->links, new_link);
 	}
 
 	HTML_OBJECT (text)->change |= HTML_CHANGE_RECALC_PI;



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