Author: cazfi
Date: Mon Nov 2 20:02:18 2015
New Revision: 30376
URL: http://svn.gna.org/viewcvs/freeciv?rev=30376&view=rev
Log:
When client options are saved when it exits, write message about it to a log
instead of the
already closed or immediately closing output window.
Reported by Jacob Nevins <jtn>
See bug #23969
Modified:
branches/S2_5/client/client_main.c
branches/S2_5/client/clinet.c
branches/S2_5/client/gui-gtk-2.0/menu.c
branches/S2_5/client/gui-gtk-2.0/optiondlg.c
branches/S2_5/client/gui-gtk-3.0/menu.c
branches/S2_5/client/gui-gtk-3.0/optiondlg.c
branches/S2_5/client/gui-qt/menu.cpp
branches/S2_5/client/gui-qt/optiondlg.cpp
branches/S2_5/client/gui-sdl/optiondlg.c
branches/S2_5/client/gui-xaw/menu.c
branches/S2_5/client/options.c
branches/S2_5/client/options.h
branches/S2_5/utility/log.h
Modified: branches/S2_5/client/client_main.c
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/client_main.c?rev=30376&r1=30375&r2=30376&view=diff
==============================================================================
--- branches/S2_5/client/client_main.c (original)
+++ branches/S2_5/client/client_main.c Mon Nov 2 20:02:18 2015
@@ -625,6 +625,18 @@
}
/**************************************************************************
+ Write messages from option saving to the log.
+**************************************************************************/
+static void log_option_save_msg(enum log_level lvl, const char *msg, ...)
+{
+ va_list args;
+
+ va_start(args, msg);
+ log_va_list(lvl, msg, args);
+ va_end(args);
+}
+
+/**************************************************************************
Main client execution stop function. This calls ui_exit() and not the
other way around.
**************************************************************************/
@@ -636,7 +648,7 @@
}
if (save_options_on_exit) {
- options_save();
+ options_save(log_option_save_msg);
}
overview_free();
Modified: branches/S2_5/client/clinet.c
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/clinet.c?rev=30376&r1=30375&r2=30376&view=diff
==============================================================================
--- branches/S2_5/client/clinet.c (original)
+++ branches/S2_5/client/clinet.c Mon Nov 2 20:02:18 2015
@@ -323,7 +323,7 @@
client_exit();
}
if (save_options_on_exit) {
- options_save();
+ options_save(NULL);
}
}
Modified: branches/S2_5/client/gui-gtk-2.0/menu.c
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-gtk-2.0/menu.c?rev=30376&r1=30375&r2=30376&view=diff
==============================================================================
--- branches/S2_5/client/gui-gtk-2.0/menu.c (original)
+++ branches/S2_5/client/gui-gtk-2.0/menu.c Mon Nov 2 20:02:18 2015
@@ -136,7 +136,7 @@
*****************************************************************/
static void save_options_callback(GtkAction *action, gpointer data)
{
- options_save();
+ options_save(NULL);
}
/****************************************************************
Modified: branches/S2_5/client/gui-gtk-2.0/optiondlg.c
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-gtk-2.0/optiondlg.c?rev=30376&r1=30375&r2=30376&view=diff
==============================================================================
--- branches/S2_5/client/gui-gtk-2.0/optiondlg.c (original)
+++ branches/S2_5/client/gui-gtk-2.0/optiondlg.c Mon Nov 2 20:02:18 2015
@@ -118,7 +118,7 @@
break;
case RESPONSE_SAVE:
desired_settable_options_update();
- options_save();
+ options_save(NULL);
break;
}
}
Modified: branches/S2_5/client/gui-gtk-3.0/menu.c
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-gtk-3.0/menu.c?rev=30376&r1=30375&r2=30376&view=diff
==============================================================================
--- branches/S2_5/client/gui-gtk-3.0/menu.c (original)
+++ branches/S2_5/client/gui-gtk-3.0/menu.c Mon Nov 2 20:02:18 2015
@@ -136,7 +136,7 @@
*****************************************************************/
static void save_options_callback(GtkAction *action, gpointer data)
{
- options_save();
+ options_save(NULL);
}
/****************************************************************
Modified: branches/S2_5/client/gui-gtk-3.0/optiondlg.c
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-gtk-3.0/optiondlg.c?rev=30376&r1=30375&r2=30376&view=diff
==============================================================================
--- branches/S2_5/client/gui-gtk-3.0/optiondlg.c (original)
+++ branches/S2_5/client/gui-gtk-3.0/optiondlg.c Mon Nov 2 20:02:18 2015
@@ -118,7 +118,7 @@
break;
case RESPONSE_SAVE:
desired_settable_options_update();
- options_save();
+ options_save(NULL);
break;
}
}
Modified: branches/S2_5/client/gui-qt/menu.cpp
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/menu.cpp?rev=30376&r1=30375&r2=30376&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/menu.cpp (original)
+++ branches/S2_5/client/gui-qt/menu.cpp Mon Nov 2 20:02:18 2015
@@ -1966,7 +1966,7 @@
*****************************************************************/
void mr_menu::save_options_now()
{
- options_save();
+ options_save(NULL);
}
/***************************************************************************
Modified: branches/S2_5/client/gui-qt/optiondlg.cpp
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/optiondlg.cpp?rev=30376&r1=30375&r2=30376&view=diff
==============================================================================
--- branches/S2_5/client/gui-qt/optiondlg.cpp (original)
+++ branches/S2_5/client/gui-qt/optiondlg.cpp Mon Nov 2 20:02:18 2015
@@ -174,7 +174,7 @@
break;
case RESPONSE_SAVE:
desired_settable_options_update();
- options_save();
+ options_save(NULL);
break;
case RESPONSE_RESET:
full_reset();
Modified: branches/S2_5/client/gui-sdl/optiondlg.c
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-sdl/optiondlg.c?rev=30376&r1=30375&r2=30376&view=diff
==============================================================================
--- branches/S2_5/client/gui-sdl/optiondlg.c (original)
+++ branches/S2_5/client/gui-sdl/optiondlg.c Mon Nov 2 20:02:18 2015
@@ -343,7 +343,7 @@
static int save_client_options_callback(struct widget *pWidget)
{
if (Main.event.button.button == SDL_BUTTON_LEFT) {
- options_save();
+ options_save(NULL);
}
return -1;
}
Modified: branches/S2_5/client/gui-xaw/menu.c
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-xaw/menu.c?rev=30376&r1=30375&r2=30376&view=diff
==============================================================================
--- branches/S2_5/client/gui-xaw/menu.c (original)
+++ branches/S2_5/client/gui-xaw/menu.c Mon Nov 2 20:02:18 2015
@@ -569,7 +569,7 @@
popup_messageopt_dialog();
break;
case MENU_GAME_SAVE_SETTINGS:
- options_save();
+ options_save(NULL);
break;
case MENU_GAME_SERVER_OPTIONS:
option_dialog_popup(_("Game Settings"), server_optset);
Modified: branches/S2_5/client/options.c
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/options.c?rev=30376&r1=30375&r2=30376&view=diff
==============================================================================
--- branches/S2_5/client/options.c (original)
+++ branches/S2_5/client/options.c Mon Nov 2 20:02:18 2015
@@ -5272,16 +5272,33 @@
}
/**************************************************************************
+ Write messages from option saving to the output window.
+**************************************************************************/
+static void option_save_output_window_callback(enum log_level lvl,
+ const char *msg, ...)
+{
+ va_list args;
+
+ va_start(args, msg);
+ output_window_vprintf(ftc_client, msg, args);
+ va_end(args);
+}
+
+/**************************************************************************
Save all options.
**************************************************************************/
-void options_save(void)
+void options_save(option_save_log_callback log_cb)
{
struct section_file *sf;
const char *name = get_current_option_file_name();
+ if (log_cb == NULL) {
+ /* Default callback */
+ log_cb = option_save_output_window_callback;
+ }
+
if (!name) {
- output_window_append(ftc_client,
- _("Save failed, cannot find a filename."));
+ log_cb(LOG_ERROR, _("Save failed, cannot find a filename."));
return;
}
@@ -5311,10 +5328,9 @@
/* save to disk */
if (!secfile_save(sf, name, 0, FZ_PLAIN)) {
- output_window_printf(ftc_client,
- _("Save failed, cannot write to file %s"), name);
+ log_cb(LOG_ERROR, _("Save failed, cannot write to file %s"), name);
} else {
- output_window_printf(ftc_client, _("Saved settings to file %s"), name);
+ log_cb(LOG_VERBOSE, _("Saved settings to file %s"), name);
}
secfile_destroy(sf);
}
Modified: branches/S2_5/client/options.h
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/options.h?rev=30376&r1=30375&r2=30376&view=diff
==============================================================================
--- branches/S2_5/client/options.h (original)
+++ branches/S2_5/client/options.h Mon Nov 2 20:02:18 2015
@@ -233,6 +233,7 @@
struct option; /* Opaque type. */
struct option_set; /* Opaque type. */
+typedef void (*option_save_log_callback)(enum log_level lvl, const char *msg,
...);
/* Main functions. */
void options_init(void);
@@ -240,7 +241,7 @@
void server_options_init(void);
void server_options_free(void);
void options_load(void);
-void options_save(void);
+void options_save(option_save_log_callback log_cb);
/* Option sets. */
Modified: branches/S2_5/utility/log.h
URL:
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/utility/log.h?rev=30376&r1=30375&r2=30376&view=diff
==============================================================================
--- branches/S2_5/utility/log.h (original)
+++ branches/S2_5/utility/log.h Mon Nov 2 20:02:18 2015
@@ -108,6 +108,12 @@
# define log_debug(message, ...) /* Do nothing. */
#endif /* DEBUG */
+#define log_va_list(level, msg, args) \
+ if (log_do_output_for_level(level)) { \
+ vdo_log(__FILE__, __FUNCTION__, __FC_LINE__, FALSE, \
+ level, msg, args); \
+ }
+
/* Used by game debug command */
#define log_test log_normal
#define log_packet log_verbose
_______________________________________________
Freeciv-commits mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-commits