[gthumb] GthTestCategory: fixed possible crashes



commit c077f8ad588a261cba1fc30583c64534f9534215
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Tue Mar 6 16:19:30 2012 +0100

    GthTestCategory: fixed possible crashes
    
    *) do not connect to the "tags-changed" signal more than once;
    *) reset the tag store when the control is destroyed.

 gthumb/gth-test-category.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/gthumb/gth-test-category.c b/gthumb/gth-test-category.c
index f7ca177..9c47a1a 100644
--- a/gthumb/gth-test-category.c
+++ b/gthumb/gth-test-category.c
@@ -174,7 +174,10 @@ static void
 monitor_tags_changed_cb (GthMonitor *monitor,
 		 	 gpointer    user_data)
 {
-	update_tag_list (GTH_TEST_CATEGORY (user_data));
+	GthTestCategory *test = user_data;
+
+	if (test->priv->tag_store != NULL)
+		update_tag_list (test);
 }
 
 
@@ -188,6 +191,10 @@ gth_test_category_real_create_control (GthTest *base)
 	test = (GthTestCategory *) base;
 
 	control = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+	g_signal_connect (control,
+			  "destroy",
+			  G_CALLBACK (gtk_widget_destroyed),
+			  &test->priv->tag_store);
 
 	/* text operation combo box */
 
@@ -238,10 +245,11 @@ gth_test_category_real_create_control (GthTest *base)
 			  "changed",
 			  G_CALLBACK (combo_entry_changed_cb),
 			  test);
-	test->priv->monitor_events = g_signal_connect (gth_main_get_default_monitor (),
-						       "tags-changed",
-						       G_CALLBACK (monitor_tags_changed_cb),
-						       test);
+	if (test->priv->monitor_events == 0)
+		test->priv->monitor_events = g_signal_connect (gth_main_get_default_monitor (),
+							       "tags-changed",
+							       G_CALLBACK (monitor_tags_changed_cb),
+							       test);
 	/**/
 
 	gtk_box_pack_start (GTK_BOX (control), test->priv->op_combo_box, FALSE, FALSE, 0);



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