On Mon, 24 May 2010 20:32:33 +1000 Lex Trotman <ele...@gmail.com> wrote:
> On 24 May 2010 18:18, Dimitar Zhekov <hams...@mbox.contact.bg> wrote: > > > > If we want the filetype save to be consistent with "Edit -> Preferences" > > and "Project -> Properties", I think the commands should be saved on > > "Build -> Set build commands", for both main and secondary sessions. > > And since there is nothing else to be saved, main_quit() will not need > > to do filetypes_save_commands(), hence no race. > > Sounds like a plan. Here it is then. > > (BTW, closing 2+ Wordpad-s works just fine for us - the save prompts > > appear one by one. Win~1 waits for a program to close before asking > > the next program to quit.) > > > > But what happens when there are no unsaved files to use the user as > the serialising critical section :) The save prompts one-by-one means that Win~1 sends WM_QUIT to foo.exe, waits for the message to be processed (i.e. the foo.exe to be closed), and only then sends WM_QUIT to bar.exe. That's fine even if there are no unsaved files. I only needed the prompts as a visual indicator of the message processing, not as serializer. -- E-gards: Jimmy
--- ./src/build.c.orig 2010-05-14 14:24:08.000000000 +0300 +++ ./src/build.c 2010-05-24 15:35:45.000000000 +0300 @@ -2206,7 +2206,7 @@ } prefdsts.nonfileregexstr = ®ex_pref; if (build_read_commands(&prefdsts, table_data, response) && ft != NULL) - ft->home_save_needed = TRUE; + filetypes_save_commands(ft); build_free_fields(table_data); build_menu_update(doc); --- ./src/filetypes.c.orig 2010-05-14 14:24:09.000000000 +0300 +++ ./src/filetypes.c 2010-05-24 14:49:31.000000000 +0300 @@ -1343,16 +1343,15 @@ } -gchar *filetypes_get_conf_extension(gint filetype_idx) +static gchar *get_filetype_conf_extension(const GeanyFiletype *ft) { gchar *result; - GeanyFiletype *ft = filetypes[filetype_idx]; if (ft->priv->custom) return g_strconcat(ft->name, ".conf", NULL); /* Handle any special extensions different from lowercase filetype->name */ - switch (filetype_idx) + switch (ft->id) { case GEANY_FILETYPES_CPP: result = g_strdup("cpp"); break; case GEANY_FILETYPES_CS: result = g_strdup("cs"); break; @@ -1363,33 +1362,29 @@ } -void filetypes_save_commands(void) +gchar *filetypes_get_conf_extension(gint filetype_idx) { - gchar *conf_prefix = g_strconcat(app->configdir, - G_DIR_SEPARATOR_S GEANY_FILEDEFS_SUBDIR G_DIR_SEPARATOR_S "filetypes.", NULL); - guint i; + return get_filetype_conf_extension(filetypes[filetype_idx]); +} - for (i = 1; i < filetypes_array->len; i++) - { - GKeyFile *config_home; - gchar *fname, *ext, *data; - if (filetypes[i]->home_save_needed) - { - ext = filetypes_get_conf_extension(i); - fname = g_strconcat(conf_prefix, ext, NULL); - g_free(ext); - config_home = g_key_file_new(); - g_key_file_load_from_file(config_home, fname, G_KEY_FILE_KEEP_COMMENTS, NULL); - build_save_menu(config_home, (gpointer)(filetypes[i]), GEANY_BCS_HOME_FT); - data = g_key_file_to_data(config_home, NULL, NULL); - utils_write_file(fname, data); - g_free(data); - g_key_file_free(config_home); - g_free(fname); - } - } - g_free(conf_prefix); +void filetypes_save_commands(const GeanyFiletype *ft) +{ + gchar *ext = get_filetype_conf_extension(ft); + gchar *fname = g_strconcat(app->configdir, + G_DIR_SEPARATOR_S GEANY_FILEDEFS_SUBDIR G_DIR_SEPARATOR_S "filetypes.", ext, NULL); + GKeyFile *config_home; + gchar *data; + + config_home = g_key_file_new(); + g_key_file_load_from_file(config_home, fname, G_KEY_FILE_KEEP_COMMENTS, NULL); + build_save_menu(config_home, (gpointer)(ft), GEANY_BCS_HOME_FT); + data = g_key_file_to_data(config_home, NULL, NULL); + utils_write_file(fname, data); + g_free(data); + g_key_file_free(config_home); + g_free(fname); + g_free(ext); } @@ -1635,9 +1630,6 @@ guint i; GeanyDocument *current_doc; - /* save possibly changed commands before re-reading them */ - filetypes_save_commands(); - /* reload filetype configs */ for (i = 0; i < filetypes_array->len; i++) { --- ./src/filetypes.h.orig 2010-05-14 14:24:09.000000000 +0300 +++ ./src/filetypes.h 2010-05-24 14:10:12.000000000 +0300 @@ -139,7 +139,6 @@ gint project_list_entry; gchar *projerror_regex_string; gchar *homeerror_regex_string; - gboolean home_save_needed; #endif }; @@ -179,7 +178,7 @@ void filetypes_load_config(gint ft_id, gboolean reload); -void filetypes_save_commands(void); +void filetypes_save_commands(const GeanyFiletype *ft); void filetypes_select_radio_item(const GeanyFiletype *ft); --- ./src/main.c.orig 2010-05-19 11:52:31.000000000 +0300 +++ ./src/main.c 2010-05-24 14:19:40.000000000 +0300 @@ -1132,7 +1132,6 @@ navqueue_free(); keybindings_free(); - filetypes_save_commands(); highlighting_free_styles(); templates_free_templates(); msgwin_finalize();
_______________________________________________ Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel