[evolution/webkit-composer: 53/130] Valgrind time



commit 713e5ecb1df6707fe48cdc683acb31deffe1713b
Author: Dan VrÃtil <dvratil redhat com>
Date:   Mon Aug 20 20:50:12 2012 +0200

    Valgrind time

 e-util/e-color-combo.c          |    2 ++
 e-util/e-editor-actions.c       |   23 ++++++++++++++---------
 e-util/e-editor-cell-dialog.c   |    7 +++++++
 e-util/e-editor-hrule-dialog.c  |   10 ++++++----
 e-util/e-editor-page-dialog.c   |    9 ++++++---
 e-util/e-editor-spell-checker.c |    4 ++++
 e-util/e-editor-table-dialog.c  |    8 ++++++--
 e-util/e-editor-widget.c        |    9 ++++++++-
 e-util/e-editor.c               |   14 +++++++++++++-
 9 files changed, 66 insertions(+), 20 deletions(-)
---
diff --git a/e-util/e-color-combo.c b/e-util/e-color-combo.c
index 400d606..f426aef 100644
--- a/e-util/e-color-combo.c
+++ b/e-util/e-color-combo.c
@@ -526,6 +526,8 @@ color_combo_dispose (GObject *object)
 		priv->default_color = NULL;
 	}
 
+	g_clear_object (&priv->chooser_widget);
+
 	/* Chain up to parent's dispose() method. */
 	G_OBJECT_CLASS (e_color_combo_parent_class)->dispose (object);
 }
diff --git a/e-util/e-editor-actions.c b/e-util/e-editor-actions.c
index 11e5ad0..84254a7 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -618,6 +618,8 @@ action_language_cb (GtkToggleAction *action,
 	gtk_action_set_sensitive (ACTION (SPELL_CHECK), length > 0);
 
 	e_editor_emit_spell_languages_changed (editor);
+
+	e_editor_spell_checker_free_dict (checker, dictionary);
 }
 
 struct _ModeChanged {
@@ -1686,7 +1688,7 @@ editor_actions_setup_languages_menu (EEditor *editor)
 	EEditorSpellChecker *checker;
 	GtkUIManager *manager;
 	GtkActionGroup *action_group;
-	const GList *available_dicts;
+	GList *available_dicts, *iter;
 	guint merge_id;
 
 	manager = editor->priv->manager;
@@ -1695,8 +1697,8 @@ editor_actions_setup_languages_menu (EEditor *editor)
 	available_dicts = e_editor_spell_checker_get_available_dicts (checker);
 	merge_id = gtk_ui_manager_new_merge_id (manager);
 
-	while (available_dicts != NULL) {
-		EnchantDict *dictionary = available_dicts->data;
+	for (iter = available_dicts; iter; iter = iter->next) {
+		EnchantDict *dictionary = iter->data;
 		GtkToggleAction *action;
 
 		action = gtk_toggle_action_new (
@@ -1720,8 +1722,10 @@ editor_actions_setup_languages_menu (EEditor *editor)
 			e_editor_spell_checker_get_dict_code (dictionary),
 			GTK_UI_MANAGER_AUTO, FALSE);
 
-		available_dicts = g_list_next (available_dicts);
+		e_editor_spell_checker_free_dict (checker, dictionary);
 	}
+
+	g_list_free (available_dicts);
 }
 
 static void
@@ -1730,7 +1734,7 @@ editor_actions_setup_spell_check_menu (EEditor *editor)
 	EEditorSpellChecker *checker;
 	GtkUIManager *manager;
 	GtkActionGroup *action_group;
-	const GList *available_dicts;
+	GList *available_dicts, *iter;
 	guint merge_id;
 
 	manager = editor->priv->manager;
@@ -1739,8 +1743,8 @@ editor_actions_setup_spell_check_menu (EEditor *editor)
 	available_dicts = e_editor_spell_checker_get_available_dicts (checker);
 	merge_id = gtk_ui_manager_new_merge_id (manager);
 
-	while (available_dicts != NULL) {
-		EnchantDict *dictionary = available_dicts->data;
+	for (iter = available_dicts; iter; iter = iter->next) {
+		EnchantDict *dictionary = iter->data;
 		GtkAction *action;
 		const gchar *code;
 		const gchar *name;
@@ -1794,11 +1798,12 @@ editor_actions_setup_spell_check_menu (EEditor *editor)
 			action_name, action_name,
 			GTK_UI_MANAGER_AUTO, FALSE);
 
+		e_editor_spell_checker_free_dict (checker, dictionary);
 		g_free (action_label);
 		g_free (action_name);
-
-		available_dicts = g_list_next (available_dicts);
 	}
+
+	g_list_free (available_dicts);
 }
 
 void
diff --git a/e-util/e-editor-cell-dialog.c b/e-util/e-editor-cell-dialog.c
index c3995d0..ba21ec5 100644
--- a/e-util/e-editor-cell-dialog.c
+++ b/e-util/e-editor-cell-dialog.c
@@ -239,6 +239,8 @@ editor_cell_dialog_set_valign (EEditorCellDialog *dialog)
 
 	editor_cell_dialog_set_attribute (
 		dialog, webkit_dom_html_table_cell_element_set_v_align, &val, NULL);
+
+	g_value_unset (&val);
 }
 
 static void
@@ -254,6 +256,8 @@ editor_cell_dialog_set_halign (EEditorCellDialog *dialog)
 
 	editor_cell_dialog_set_attribute (
 		dialog, webkit_dom_html_table_cell_element_set_align, &val, NULL);
+
+	g_value_unset (&val);
 }
 
 static void
@@ -295,6 +299,7 @@ cell_set_header_style (WebKitDOMHTMLTableCellElement *cell,
 		new_cell = webkit_dom_document_create_element (document, "TD", NULL);
 
 	} else {
+		g_free (tagname);
 		return;
 	}
 
@@ -321,6 +326,8 @@ cell_set_header_style (WebKitDOMHTMLTableCellElement *cell,
 		WEBKIT_DOM_NODE (cell), NULL);
 
 	dialog->priv->cell = new_cell;
+
+	g_free (tagname);
 }
 
 static void
diff --git a/e-util/e-editor-hrule-dialog.c b/e-util/e-editor-hrule-dialog.c
index 110b033..0f2134f 100644
--- a/e-util/e-editor-hrule-dialog.c
+++ b/e-util/e-editor-hrule-dialog.c
@@ -50,7 +50,7 @@ editor_hrule_dialog_set_alignment (EEditorHRuleDialog *dialog)
 
 	g_return_if_fail (WEBKIT_DOM_IS_HTMLHR_ELEMENT (dialog->priv->hr_element));
 
-	alignment = gtk_combo_box_text_get_active_text (
+	alignment = gtk_combo_box_get_active_id (
 			GTK_COMBO_BOX_TEXT (dialog->priv->alignment_combo));
 
 	webkit_dom_htmlhr_element_set_align (dialog->priv->hr_element, alignment);
@@ -113,19 +113,21 @@ editor_hrule_dialog_get_size (EEditorHRuleDialog *dialog)
 static void
 editor_hrule_dialog_set_width (EEditorHRuleDialog *dialog)
 {
-	gchar *width;
+	gchar *width, *units;
 
 	g_return_if_fail (WEBKIT_DOM_IS_HTMLHR_ELEMENT (dialog->priv->hr_element));
 
+	units = gtk_combo_box_text_get_active_text (
+			GTK_COMBO_BOX_TEXT (dialog->priv->unit_combo));
 	width = g_strdup_printf (
 		"%d%s",
 		(gint) gtk_spin_button_get_value (
 			GTK_SPIN_BUTTON (dialog->priv->width_edit)),
-		gtk_combo_box_text_get_active_text (
-			GTK_COMBO_BOX_TEXT (dialog->priv->unit_combo)));
+		units);
 
 	webkit_dom_htmlhr_element_set_width (dialog->priv->hr_element, width);
 
+	g_free (units);
 	g_free (width);
 }
 
diff --git a/e-util/e-editor-page-dialog.c b/e-util/e-editor-page-dialog.c
index 3327361..6976172 100644
--- a/e-util/e-editor-page-dialog.c
+++ b/e-util/e-editor-page-dialog.c
@@ -268,6 +268,8 @@ editor_page_dialog_set_background_image (EEditorPageDialog *dialog)
 
 	webkit_dom_html_body_element_set_background (
 		(WebKitDOMHTMLBodyElement *) body, uri ? uri : "");
+
+	g_free (uri);
 }
 
 static void
@@ -308,6 +310,7 @@ editor_page_dialog_show (GtkWidget *widget)
 		gtk_combo_box_set_active (
 			GTK_COMBO_BOX (dialog->priv->background_template_combo), 0);
 	}
+	g_free (tmp);
 
 	tmp = webkit_dom_html_body_element_get_text (
 			(WebKitDOMHTMLBodyElement *) body);
@@ -322,8 +325,8 @@ editor_page_dialog_show (GtkWidget *widget)
 		rgba.blue = ((gdouble) color->blue) / G_MAXUINT16;
 	} else {
 		gdk_rgba_parse (&rgba, tmp);
-		g_free (tmp);
 	}
+	g_free (tmp);
 	e_color_combo_set_current_color (
 		E_COLOR_COMBO (dialog->priv->text_color_picker), &rgba);
 
@@ -340,8 +343,8 @@ editor_page_dialog_show (GtkWidget *widget)
 		rgba.blue = ((gdouble) color.blue) / G_MAXUINT16;
 	} else {
 		gdk_rgba_parse (&rgba, tmp);
-		g_free (tmp);
 	}
+	g_free (tmp);
 	e_color_combo_set_current_color (
 		E_COLOR_COMBO (dialog->priv->link_color_picker), &rgba);
 
@@ -359,8 +362,8 @@ editor_page_dialog_show (GtkWidget *widget)
 
 	} else {
 		gdk_rgba_parse (&rgba, tmp);
-		g_free (tmp);
 	}
+	g_free (tmp);
 	e_color_combo_set_current_color (
 		E_COLOR_COMBO (dialog->priv->background_color_picker), &rgba);
 
diff --git a/e-util/e-editor-spell-checker.c b/e-util/e-editor-spell-checker.c
index b7c100f..143a501 100644
--- a/e-util/e-editor-spell-checker.c
+++ b/e-util/e-editor-spell-checker.c
@@ -457,8 +457,12 @@ check_spelling_of_string (WebKitSpellChecker *webkit_checker,
                     			break;
                 		}
             		}
+
+            		g_free (new_word);
         	}
     	}
+
+    	g_free (attrs);
 }
 
 static gchar **
diff --git a/e-util/e-editor-table-dialog.c b/e-util/e-editor-table-dialog.c
index a3a8a71..446f4e0 100644
--- a/e-util/e-editor-table-dialog.c
+++ b/e-util/e-editor-table-dialog.c
@@ -201,13 +201,16 @@ editor_table_dialog_set_width (EEditorTableDialog *dialog)
 
 	if (gtk_toggle_button_get_active (
 			GTK_TOGGLE_BUTTON (dialog->priv->width_check))) {
+		gchar *units;
 
+		units = gtk_combo_box_text_get_active_text (
+				GTK_COMBO_BOX_TEXT (dialog->priv->width_units));
 		width = g_strdup_printf (
 			"%d%s",
 			gtk_spin_button_get_value_as_int (
 				GTK_SPIN_BUTTON (dialog->priv->width_edit)),
-			gtk_combo_box_text_get_active_text (
-				GTK_COMBO_BOX_TEXT (dialog->priv->width_units)));
+			units);
+		g_free (units);
 
 		gtk_widget_set_sensitive (dialog->priv->width_edit, TRUE);
 		gtk_widget_set_sensitive (dialog->priv->width_units, TRUE);
@@ -248,6 +251,7 @@ editor_table_dialog_get_width (EEditorTableDialog *dialog)
 			((strstr (width, "%") == NULL) ?
 				"units-px" : "units-percent"));
 	}
+	g_free (width);
 }
 
 static void
diff --git a/e-util/e-editor-widget.c b/e-util/e-editor-widget.c
index 2712423..7d5a39a 100644
--- a/e-util/e-editor-widget.c
+++ b/e-util/e-editor-widget.c
@@ -291,8 +291,10 @@ editor_widget_check_magic_smileys (EEditorWidget *widget,
 
 		if (pos > 0) {
 			uc = g_utf8_get_char (g_utf8_offset_to_pointer (node_text, pos - 1));
-			if (uc != ' ' && uc != '\t')
+			if (uc != ' ' && uc != '\t') {
+				g_free (node_text);
 				return;
+			}
 		}
 
 		/* Select the text-smiley and replace it by <img> */
@@ -319,6 +321,8 @@ editor_widget_check_magic_smileys (EEditorWidget *widget,
 		g_free (filename_uri);
 		gtk_icon_info_free (icon_info);
 	}
+
+	g_free (node_text);
 }
 
 static void
@@ -410,6 +414,8 @@ editor_widget_button_release_event (GtkWidget *gtk_widget,
 	        "link-uri", &uri,
 	       	NULL);
 
+	g_object_unref (hit_test);
+
 	/* Left click on a link */
 	if ((context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK) &&
 	    (event->button == 1)) {
@@ -761,6 +767,7 @@ e_editor_widget_init (EEditorWidget *editor)
 	/* Override the spell-checker, use our own */
 	checker = g_object_new (E_TYPE_EDITOR_SPELL_CHECKER, NULL);
 	webkit_set_text_checker (G_OBJECT (checker));
+	g_object_unref (checker);
 
 	/* Don't use CSS when possible to preserve compatibility with older
 	 * versions of Evolution or other MUAs */
diff --git a/e-util/e-editor.c b/e-util/e-editor.c
index 4db0e09..92916ad 100644
--- a/e-util/e-editor.c
+++ b/e-util/e-editor.c
@@ -308,6 +308,7 @@ editor_update_actions (EEditor *editor,
 		G_OBJECT (hit_test),
 		"context", &context,
 	        "inner-node", &node, NULL);
+	g_object_unref (hit_test);
 
 	visible = (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE);
 	gtk_action_set_visible (ACTION (CONTEXT_PROPERTIES_IMAGE), visible);
@@ -686,13 +687,19 @@ editor_constructed (GObject *object)
 }
 
 static void
+free_dict (gpointer dict,
+	   gpointer checker)
+{
+	e_editor_spell_checker_free_dict (checker, dict);
+}
+
+static void
 editor_dispose (GObject *object)
 {
 	EEditor *editor = E_EDITOR (object);
 	EEditorPrivate *priv = editor->priv;
 
 	g_clear_object (&priv->manager);
-	g_clear_object (&priv->manager);
 	g_clear_object (&priv->core_actions);
 	g_clear_object (&priv->html_actions);
 	g_clear_object (&priv->context_actions);
@@ -701,6 +708,9 @@ editor_dispose (GObject *object)
 	g_clear_object (&priv->spell_check_actions);
 	g_clear_object (&priv->suggestion_actions);
 
+	g_list_foreach (
+		priv->active_dictionaries, free_dict,
+		webkit_get_text_checker());
 	g_list_free (priv->active_dictionaries);
 	priv->active_dictionaries = NULL;
 
@@ -715,6 +725,8 @@ editor_dispose (GObject *object)
 	g_clear_object (&priv->size_combo_box);
 	g_clear_object (&priv->style_combo_box);
 	g_clear_object (&priv->scrolled_window);
+
+	g_clear_object (&priv->editor_widget);
 }
 
 static void



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