SF.net SVN: geany:[4881] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Fri May 7 13:21:33 UTC 2010


Revision: 4881
          http://geany.svn.sourceforge.net/geany/?rev=4881&view=rev
Author:   ntrel
Date:     2010-05-07 13:21:32 +0000 (Fri, 07 May 2010)

Log Message:
-----------
Avoid connecting signals more than once.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/templates.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-05-07 00:49:40 UTC (rev 4880)
+++ trunk/ChangeLog	2010-05-07 13:21:32 UTC (rev 4881)
@@ -1,3 +1,9 @@
+2010-05-07  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/templates.c:
+   Avoid connecting signals more than once.
+
+
 2010-05-06  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
 
  * wscript:
@@ -10,7 +16,7 @@
  * src/build.c:
    Fix marking some strings as translatable (cannot be done in the
    ASSIGNIF macro).
- * src/templates.c:
+ * src/templates.c, doc/geany.txt, doc/geany.html:
    Reload templates if saving a document in the templates config dir.
 
 

Modified: trunk/src/templates.c
===================================================================
--- trunk/src/templates.c	2010-05-07 00:49:40 UTC (rev 4880)
+++ trunk/src/templates.c	2010-05-07 13:21:32 UTC (rev 4881)
@@ -481,12 +481,13 @@
 }
 
 
+/* warning: also called when reloading template settings */
 void templates_init(void)
 {
 	gchar *year = utils_get_date_time(template_prefs.year_format, NULL);
 	gchar *date = utils_get_date_time(template_prefs.date_format, NULL);
 	gchar *datetime = utils_get_date_time(template_prefs.datetime_format, NULL);
-	GtkWidget *item;
+	static gboolean init_done = FALSE;
 
 	init_general_templates(year, date, datetime);
 	init_ft_templates(year, date, datetime);
@@ -499,13 +500,19 @@
 	/* we hold our own ref for the menu as it has no parent whilst being moved */
 	g_object_ref(new_with_template_menu);
 
-	/* reparent the template menu as needed */
-	item = ui_lookup_widget(main_widgets.window, "file1");
-	item = gtk_menu_item_get_submenu(GTK_MENU_ITEM(item));
-	g_signal_connect(item, "show", G_CALLBACK(on_file_menu_show), NULL);
-	g_signal_connect(item, "hide", G_CALLBACK(on_file_menu_hide), NULL);
+	/* only connect signals to persistent objects once */
+	if (!init_done)
+	{
+		GtkWidget *item;
+		/* reparent the template menu as needed */
+		item = ui_lookup_widget(main_widgets.window, "file1");
+		item = gtk_menu_item_get_submenu(GTK_MENU_ITEM(item));
+		g_signal_connect(item, "show", G_CALLBACK(on_file_menu_show), NULL);
+		g_signal_connect(item, "hide", G_CALLBACK(on_file_menu_hide), NULL);
 
-	g_signal_connect(geany_object, "document-save", G_CALLBACK(on_document_save), NULL);
+		g_signal_connect(geany_object, "document-save", G_CALLBACK(on_document_save), NULL);
+	}
+	init_done = TRUE;
 }
 
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list