Menu

#466 parse_args is called too late for client_init/config_load debug logging

None
closed
None
5
2022-12-23
2022-12-22
No
diff --git a/gtk-v2/src/main.c b/gtk-v2/src/main.c
index b6a57a6..3409f3c 100644
--- a/gtk-v2/src/main.c
+++ b/gtk-v2/src/main.c
@@ -499,11 +499,11 @@ int main(int argc, char *argv[]) {

     // Initialize GTK and client library.
     gtk_init(&argc, &argv);
+    parse_args(argc, argv);
     client_init();

     // Set defaults, load configuration, and parse arguments.
     config_load();
-    parse_args(argc, argv);
     config_check();
     char *layout = g_path_get_basename(window_xml_file);

Without this, 'crossfire-client-gtk2 -v 0' is ineffective in client_init() and config_load(). While trying to figure out why the client wasn't loading a modded .ui file, LOG(LOG_DEBUG, "config_load", ...) calls added to config.c did not work until I realized '-v 0' hadn't been registered yet.

This is a ticket primarily to allow others to comment before a change is made.

This suggestion is applicable both to the client master and the gtk3-3 branch.

Discussion

  • Kevin R. Bulgrien

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,3 +1,4 @@
    +~~~
     diff --git a/gtk-v2/src/main.c b/gtk-v2/src/main.c
     index b6a57a6..3409f3c 100644
     --- a/gtk-v2/src/main.c
    @@ -14,6 +15,7 @@
     -    parse_args(argc, argv);
          config_check();
          char *layout = g_path_get_basename(window_xml_file);
    +~~~
    
     Without this,  'crossfire-client-gtk2 -v 0' is ineffective in client_init() and config_load().  While trying to figure out why the client wasn't loading a modded .ui file, LOG(LOG_DEBUG, "config_load", ...) calls added to config.c did not work until I realized '-v 0' hadn't been registered yet.
    
    • Group: -->
     
  • Kevin Zheng

    Kevin Zheng - 2022-12-22

    Are there any configuration options in the configuration file that would override the values set on the command line? If not, seems okay.

     
  • Kevin R. Bulgrien

    From my perspective, and along the lines of the principle of least surprise, a command-line argument should usually override a setting from a config file, though I guess there is a potential case to consider if a command-line argument specifies a config file to use. It would likely feel wrong to manually type a command-line with a switch only to have it be ignored.

     

    Last edit: Kevin R. Bulgrien 2022-12-22
  • Kevin R. Bulgrien

    • status: open --> closed
    • assigned_to: Kevin R. Bulgrien
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.