Revision: 4275 http://geany.svn.sourceforge.net/geany/?rev=4275&view=rev Author: ntrel Date: 2009-10-01 11:06:08 +0000 (Thu, 01 Oct 2009)
Log Message: ----------- Fix wrong creation of filetype template menu items for custom filetypes.
Modified Paths: -------------- trunk/ChangeLog trunk/src/templates.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-09-30 19:44:59 UTC (rev 4274) +++ trunk/ChangeLog 2009-10-01 11:06:08 UTC (rev 4275) @@ -1,3 +1,10 @@ +2009-10-01 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> + + * src/templates.c: + Fix wrong creation of filetype template menu items for custom + filetypes. + + 2009-09-30 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/symbols.c:
Modified: trunk/src/templates.c =================================================================== --- trunk/src/templates.c 2009-09-30 19:44:59 UTC (rev 4274) +++ trunk/src/templates.c 2009-10-01 11:06:08 UTC (rev 4275) @@ -247,8 +247,7 @@
static void -on_new_with_template (GtkMenuItem *menuitem, - gpointer user_data) +on_new_with_filetype_template(GtkMenuItem *menuitem, gpointer user_data) { GeanyFiletype *ft = user_data; gchar *template = templates_get_template_new_file(ft); @@ -259,7 +258,7 @@
/* template items for the new file menu */ -static void create_new_menu_items(void) +static void create_new_filetype_items(void) { GSList *node;
@@ -269,18 +268,18 @@ GtkWidget *tmp_menu, *tmp_button; const gchar *label = ft->title;
- if (ft_templates[ft->id] == NULL) + if (ft->id >= GEANY_MAX_BUILT_IN_FILETYPES || ft_templates[ft->id] == NULL) continue;
tmp_menu = gtk_menu_item_new_with_label(label); gtk_widget_show(tmp_menu); gtk_container_add(GTK_CONTAINER(new_with_template_menu), tmp_menu); - g_signal_connect(tmp_menu, "activate", G_CALLBACK(on_new_with_template), ft); + g_signal_connect(tmp_menu, "activate", G_CALLBACK(on_new_with_filetype_template), ft);
tmp_button = gtk_menu_item_new_with_label(label); gtk_widget_show(tmp_button); gtk_container_add(GTK_CONTAINER(toolbar_new_file_menu), tmp_button); - g_signal_connect(tmp_button, "activate", G_CALLBACK(on_new_with_template), ft); + g_signal_connect(tmp_button, "activate", G_CALLBACK(on_new_with_filetype_template), ft); } }
@@ -445,7 +444,7 @@ /* we hold our own ref on the menu in case it is not used in the toolbar */ g_object_ref(toolbar_new_file_menu);
- create_new_menu_items(); + create_new_filetype_items();
sep1 = gtk_separator_menu_item_new(); gtk_container_add(GTK_CONTAINER(new_with_template_menu), sep1); @@ -605,6 +604,8 @@ { filetype_id ft_id = FILETYPE_ID(ft);
+ g_return_val_if_fail(ft_id < GEANY_MAX_BUILT_IN_FILETYPES, NULL); + return g_strdup(ft_templates[ft_id]); }
@@ -614,6 +615,8 @@ gchar *ft_template = NULL; gchar *file_header = NULL;
+ g_return_val_if_fail(ft->id < GEANY_MAX_BUILT_IN_FILETYPES, NULL); + if (FILETYPE_ID(ft) == GEANY_FILETYPES_NONE) return get_file_template(ft);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.