[gtkhtml/gnome-2-32] Bug #612344 - Crash in html_object_prev_not_type at htmlobject.c



commit 39aacb888c8b24e0ee5d1fc4a3b62dfc022f0dde
Author: Milan Crha <mcrha redhat com>
Date:   Wed Dec 1 16:08:13 2010 +0100

    Bug #612344 - Crash in html_object_prev_not_type at htmlobject.c

 components/editor/gtkhtml-editor-private.h |    3 --
 components/editor/gtkhtml-editor-signals.c |   53 +++++----------------------
 2 files changed, 10 insertions(+), 46 deletions(-)
---
diff --git a/components/editor/gtkhtml-editor-private.h b/components/editor/gtkhtml-editor-private.h
index 79fb758..d1212c2 100644
--- a/components/editor/gtkhtml-editor-private.h
+++ b/components/editor/gtkhtml-editor-private.h
@@ -154,9 +154,6 @@ struct _GtkhtmlEditorPrivate {
 
 	/*** Link Properties State ***/
 
-	HTMLObject *link_object;
-	gint link_start_offset;
-	gint link_end_offset;
 	gboolean link_custom_description;
 
 	/*** Rule Properties State ***/
diff --git a/components/editor/gtkhtml-editor-signals.c b/components/editor/gtkhtml-editor-signals.c
index 38249a9..4f04447 100644
--- a/components/editor/gtkhtml-editor-signals.c
+++ b/components/editor/gtkhtml-editor-signals.c
@@ -1029,25 +1029,6 @@ sanitize_description_text (const gchar *ptext)
 	return g_strstrip (text);
 }
 
-static void
-update_link_offsets (GtkhtmlEditor *editor)
-{
-	Link *link;
-	GtkHTML *html;
-
-	g_return_if_fail (editor != NULL);
-	g_return_if_fail (GTKHTML_IS_EDITOR (editor));
-	g_return_if_fail (editor->priv != NULL);
-
-	html = gtkhtml_editor_get_html (editor);
-
-	link = html_text_get_link_at_offset (HTML_TEXT (html->engine->cursor->object), html->engine->cursor->offset);
-	g_return_if_fail (link != NULL);
-
-	editor->priv->link_start_offset = link->start_offset;
-	editor->priv->link_end_offset = link->end_offset;
-}
-
 AUTOCONNECTED_SIGNAL_HANDLER (void
 gtkhtml_editor_link_properties_description_changed_cb (GtkWidget *window))
 {
@@ -1068,31 +1049,26 @@ gtkhtml_editor_link_properties_description_changed_cb (GtkWidget *window))
 	editor->priv->link_custom_description = (*text != '\0');
 
 	if (editor->priv->link_custom_description) {
-		gint start_offset;
-		gint end_offset;
 		glong length;
+		Link *link;
 
-		start_offset = editor->priv->link_start_offset;
-		end_offset = editor->priv->link_end_offset;
+		link = html_text_get_link_at_offset (HTML_TEXT (html->engine->cursor->object), html->engine->cursor->offset);
 		length = g_utf8_strlen (text, -1);
 
-		if (start_offset != end_offset) {
+		if (link && link->start_offset != link->end_offset) {
 			html_cursor_jump_to (
 				html->engine->cursor, html->engine,
-				editor->priv->link_object, start_offset);
+				html->engine->cursor->object, link->start_offset);
 			html_engine_set_mark (html->engine);
 			html_cursor_jump_to (
 				html->engine->cursor, html->engine,
-				editor->priv->link_object, end_offset);
+				html->engine->cursor->object, link->end_offset);
 			html_engine_delete (html->engine);
 		}
 
 		html_engine_paste_link (
 			html->engine, text, length,
 			gtk_entry_get_text (GTK_ENTRY (url_entry)));
-
-		editor->priv->link_object = html->engine->cursor->object;
-		update_link_offsets (editor);
 	}
 
 	g_free (text);
@@ -1128,31 +1104,26 @@ gtkhtml_editor_link_properties_url_changed_cb (GtkWidget *window))
 		g_free (descr);
 		editor->priv->link_custom_description = FALSE;
 	} else {
-		gint start_offset;
-		gint end_offset;
 		glong length;
+		Link *link;
 		const gchar *descr = gtk_entry_get_text (GTK_ENTRY (dsc_entry));
 
-		start_offset = editor->priv->link_start_offset;
-		end_offset = editor->priv->link_end_offset;
+		link = html_text_get_link_at_offset (HTML_TEXT (html->engine->cursor->object), html->engine->cursor->offset);
 		length = g_utf8_strlen (descr, -1);
 
-		if (start_offset != end_offset) {
+		if (link && link->start_offset != link->end_offset) {
 			html_cursor_jump_to (
 				html->engine->cursor, html->engine,
-				editor->priv->link_object, start_offset);
+				html->engine->cursor->object, link->start_offset);
 			html_engine_set_mark (html->engine);
 			html_cursor_jump_to (
 				html->engine->cursor, html->engine,
-				editor->priv->link_object, end_offset);
+				html->engine->cursor->object, link->end_offset);
 			html_engine_delete (html->engine);
 		}
 
 		html_engine_paste_link (
 			html->engine, descr, length, text);
-
-		editor->priv->link_object = html->engine->cursor->object;
-		update_link_offsets (editor);
 	}
 
 	g_free (text);
@@ -1217,10 +1188,6 @@ gtkhtml_editor_link_properties_show_window_cb (GtkWidget *window))
 		sensitive = FALSE;
 	}
 
-	editor->priv->link_object = cursor->object;
-	editor->priv->link_start_offset = start_offset;
-	editor->priv->link_end_offset = end_offset;
-
 	gtk_widget_set_sensitive (dsc_entry, sensitive);
 	gtk_entry_set_text (
 		GTK_ENTRY (url_entry),



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