Author: cazfi
Date: Sun Dec 14 20:08:44 2014
New Revision: 27300

URL: http://svn.gna.org/viewcvs/freeciv?rev=27300&view=rev
Log:
Replaced modpack installer gui specific initialization and deinitialization code
with functions in modpack installer library part. This also fixes number of bugs
of deinitialization of some components missing.

See bug #23055

Modified:
    trunk/tools/modinst.c
    trunk/tools/modinst.h
    trunk/tools/mpcli.c
    trunk/tools/mpgui_gtk2.c
    trunk/tools/mpgui_gtk3.c
    trunk/tools/mpgui_qt.cpp

Modified: trunk/tools/modinst.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/modinst.c?rev=27300&r1=27299&r2=27300&view=diff
==============================================================================
--- trunk/tools/modinst.c       (original)
+++ trunk/tools/modinst.c       Sun Dec 14 20:08:44 2014
@@ -16,9 +16,13 @@
 #endif
 
 /* utility */
+#include "fciconv.h"
 #include "fcintl.h"
 #include "log.h"
 #include "mem.h"
+#include "netintf.h"
+#include "rand.h"
+#include "registry.h"
 
 /* modinst */
 #include "mpdb.h"
@@ -162,3 +166,29 @@
 
   return NULL;
 }
+
+/**************************************************************************
+  Initialize modpack installer
+**************************************************************************/
+void fcmp_init(int loglevel)
+{
+  init_nls();
+  init_character_encodings(FC_DEFAULT_DATA_ENCODING, FALSE);
+  registry_module_init();
+
+  fc_init_network();
+
+  log_init(NULL, loglevel, NULL, NULL, -1);
+  fc_srand(time(NULL)); /* Needed at least for Windows version of 
netfile_get_section_file() */
+}
+
+/**************************************************************************
+  Deinitialize modpack installer
+**************************************************************************/
+void fcmp_deinit(void)
+{
+  registry_module_close();
+  fc_shutdown_network();
+  log_close();
+  free_nls();
+}

Modified: trunk/tools/modinst.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/modinst.h?rev=27300&r1=27299&r2=27300&view=diff
==============================================================================
--- trunk/tools/modinst.h       (original)
+++ trunk/tools/modinst.h       Sun Dec 14 20:08:44 2014
@@ -49,6 +49,9 @@
 #define SPECENUM_VALUE5NAME N_("Musicset")
 #include "specenum_gen.h"
 
+void fcmp_init(int loglevel);
+void fcmp_deinit(void);
+
 void load_install_info_lists(struct fcmp_params *fcmp);
 void save_install_info_lists(struct fcmp_params *fcmp);
 void update_install_info_lists(const char *name,

Modified: trunk/tools/mpcli.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/mpcli.c?rev=27300&r1=27299&r2=27300&view=diff
==============================================================================
--- trunk/tools/mpcli.c (original)
+++ trunk/tools/mpcli.c Sun Dec 14 20:08:44 2014
@@ -18,13 +18,9 @@
 #include <stdlib.h>
 
 /* utility */
-#include "fciconv.h"
 #include "fcintl.h"
 #include "log.h"
 #include "mem.h"
-#include "netintf.h"
-#include "rand.h"
-#include "registry.h"
 #include "shared.h"
 
 /* common */
@@ -102,14 +98,7 @@
   int loglevel = LOG_NORMAL;
   int ui_options;
 
-  init_nls();
-  init_character_encodings(FC_DEFAULT_DATA_ENCODING, FALSE);
-  registry_module_init();
-
-  fc_init_network();
-
-  log_init(NULL, loglevel, NULL, NULL, -1);
-  fc_srand(time(NULL)); /* Needed at least for Windows version of 
netfile_get_section_file() */
+  fcmp_init(loglevel);
 
   /* This modifies argv! */
   ui_options = fcmp_parse_cmdline(argc, argv);
@@ -149,7 +138,7 @@
     save_install_info_lists(&fcmp);
   }
 
-  log_close();
+  fcmp_deinit();
 
   return EXIT_SUCCESS;
 }

Modified: trunk/tools/mpgui_gtk2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/mpgui_gtk2.c?rev=27300&r1=27299&r2=27300&view=diff
==============================================================================
--- trunk/tools/mpgui_gtk2.c    (original)
+++ trunk/tools/mpgui_gtk2.c    Sun Dec 14 20:08:44 2014
@@ -20,13 +20,9 @@
 #include <gtk/gtk.h>
 
 /* utility */
-#include "fciconv.h"
 #include "fcintl.h"
 #include "log.h"
 #include "mem.h"
-#include "netintf.h"
-#include "rand.h"
-#include "registry.h"
 #include "shared.h"
 
 /* common */
@@ -75,8 +71,7 @@
 {
   save_install_info_lists(&fcmp);
 
-  registry_module_close();
-  free_nls();
+  fcmp_deinit();
 
   exit(EXIT_SUCCESS);
 }
@@ -565,16 +560,9 @@
   int loglevel = LOG_NORMAL;
   int ui_options;
 
-  init_nls();
-  init_character_encodings(FC_DEFAULT_DATA_ENCODING, FALSE);
-  registry_module_init();
-
-  fc_init_network();
+  fcmp_init(loglevel);
 
   g_thread_init(NULL);
-
-  log_init(NULL, loglevel, NULL, NULL, -1);
-  fc_srand(time(NULL)); /* Needed at least for Windows version of 
netfile_get_section_file() */
 
   /* This modifies argv! */
   ui_options = fcmp_parse_cmdline(argc, argv);
@@ -620,7 +608,7 @@
     save_install_info_lists(&fcmp);
   }
 
-  log_close();
+  fcmp_deinit();
 
   return EXIT_SUCCESS;
 }

Modified: trunk/tools/mpgui_gtk3.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/mpgui_gtk3.c?rev=27300&r1=27299&r2=27300&view=diff
==============================================================================
--- trunk/tools/mpgui_gtk3.c    (original)
+++ trunk/tools/mpgui_gtk3.c    Sun Dec 14 20:08:44 2014
@@ -20,13 +20,9 @@
 #include <gtk/gtk.h>
 
 /* utility */
-#include "fciconv.h"
 #include "fcintl.h"
 #include "log.h"
 #include "mem.h"
-#include "netintf.h"
-#include "rand.h"
-#include "registry.h"
 #include "shared.h"
 
 /* common */
@@ -75,8 +71,7 @@
 {
   save_install_info_lists(&fcmp);
 
-  registry_module_close();
-  free_nls();
+  fcmp_deinit();
 
   exit(EXIT_SUCCESS);
 }
@@ -573,14 +568,7 @@
   int loglevel = LOG_NORMAL;
   int ui_options;
 
-  init_nls();
-  init_character_encodings(FC_DEFAULT_DATA_ENCODING, FALSE);
-  registry_module_init();
-
-  fc_init_network();
-
-  log_init(NULL, loglevel, NULL, NULL, -1);
-  fc_srand(time(NULL)); /* Needed at least for Windows version of 
netfile_get_section_file() */
+  fcmp_init(loglevel);
 
   /* This modifies argv! */
   ui_options = fcmp_parse_cmdline(argc, argv);
@@ -626,7 +614,7 @@
     save_install_info_lists(&fcmp);
   }
 
-  log_close();
+  fcmp_deinit();
 
   return EXIT_SUCCESS;
 }

Modified: trunk/tools/mpgui_qt.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/mpgui_qt.cpp?rev=27300&r1=27299&r2=27300&view=diff
==============================================================================
--- trunk/tools/mpgui_qt.cpp    (original)
+++ trunk/tools/mpgui_qt.cpp    Sun Dec 14 20:08:44 2014
@@ -28,12 +28,8 @@
 #include <QVBoxLayout>
 
 // utility
-#include "fciconv.h"
 #include "fcintl.h"
 #include "log.h"
-#include "netintf.h"
-#include "rand.h"
-#include "registry.h"
 
 // common
 #include "version.h"
@@ -84,12 +80,7 @@
   enum log_level loglevel = LOG_NORMAL;
   int ui_options;
 
-  init_nls();
-  init_character_encodings(FC_DEFAULT_DATA_ENCODING, FALSE);
-  registry_module_init();
-  fc_init_network();
-  log_init(NULL, loglevel, NULL, NULL, -1);
-  fc_srand(time(NULL)); // Needed at least for Windows version of 
netfile_get_section_file()
+  fcmp_init(loglevel);
 
   /* This modifies argv! */
   ui_options = fcmp_parse_cmdline(argc, argv);
@@ -136,9 +127,7 @@
     save_install_info_lists(&fcmp);
   }
 
-  log_close();
-  registry_module_close();
-  free_nls();
+  fcmp_deinit();
 
   return EXIT_SUCCESS;
 }


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to