Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2006:
[Freeciv-Dev] (PR#15046) GUI-specific cleanup on exit
Home

[Freeciv-Dev] (PR#15046) GUI-specific cleanup on exit

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#15046) GUI-specific cleanup on exit
From: "Christian Prochaska" <cp.ml.freeciv.dev@xxxxxxxxxxxxxx>
Date: Sat, 7 Jan 2006 10:34:02 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=15046 >

> [cproc - So 01. Jan 2006, 22:23:40]:
> 
> Here's a patch that gives a GUI the possibility to do any necessary
> UI-specific cleanup (like freeing loaded fonts or theme graphics) on
> exit. This is currently problematic in  gui-sdl, because the last chance
> for cleanup is at the end of gui_main(), but later in ui_exit() still
> some GUI functionality is needed when save_options() calls
> append_output_window() to write a message to the screen.
> 
> The patch does the following:
> 
> - rename ui_exit() in civclient.c to client_exit()
> - add a function "ui_exit()" to the GUI part which is called by
> client_exit() when all interaction with the GUI part is finished
> 

Oops, missed one renaming in gui-xaw. Here's the corrected patch for
gui-xaw and an all-in-one patch for easy applying. If there are no
objections, please somebody commit.
Index: client/gui-xaw/gui_main.c
===================================================================
--- client/gui-xaw/gui_main.c   (Revision 11417)
+++ client/gui-xaw/gui_main.c   (Arbeitskopie)
@@ -492,7 +492,14 @@
   XtAppMainLoop(app_context);
 }
 
+/**************************************************************************
+  Do any necessary UI-specific cleanup
+**************************************************************************/
+void ui_exit()
+{
 
+}
+
 /**************************************************************************
   Callack for when user clicks one of the unit icons on left hand side
   (units on same square as current unit).  Use unit_ids[] data and change
@@ -705,7 +712,7 @@
 void xaw_ui_exit(void)
 {
   tileset_free_tiles(tileset);
-  ui_exit();
+  client_exit();
 }
 
 /**************************************************************************
Index: client/gui-xaw/dialogs.c
===================================================================
--- client/gui-xaw/dialogs.c    (Revision 11417)
+++ client/gui-xaw/dialogs.c    (Arbeitskopie)
@@ -1552,7 +1552,7 @@
 void races_quit_command_callback(Widget w, XtPointer client_data, 
                                 XtPointer call_data)
 {
-  ui_exit();
+  client_exit();
 }
 
 /**************************************************************************
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
--- client/gui-gtk-2.0/gui_main.c       (Revision 11417)
+++ client/gui-gtk-2.0/gui_main.c       (Arbeitskopie)
@@ -1305,6 +1305,14 @@
 }
 
 /**************************************************************************
+  Do any necessary UI-specific cleanup
+**************************************************************************/
+void ui_exit()
+{
+
+}
+
+/**************************************************************************
  Update the connected users list at pregame state.
 **************************************************************************/
 void update_conn_list_dialog(void)
@@ -1703,7 +1711,7 @@
 {
   gtk_widget_destroy(dialog);
   if (response == GTK_RESPONSE_YES) {
-    ui_exit();
+    client_exit();
   }
 }
 
Index: client/gui-xaw/gui_main.c
===================================================================
--- client/gui-xaw/gui_main.c   (Revision 11417)
+++ client/gui-xaw/gui_main.c   (Arbeitskopie)
@@ -492,7 +492,14 @@
   XtAppMainLoop(app_context);
 }
 
+/**************************************************************************
+  Do any necessary UI-specific cleanup
+**************************************************************************/
+void ui_exit()
+{
 
+}
+
 /**************************************************************************
   Callack for when user clicks one of the unit icons on left hand side
   (units on same square as current unit).  Use unit_ids[] data and change
@@ -705,7 +712,7 @@
 void xaw_ui_exit(void)
 {
   tileset_free_tiles(tileset);
-  ui_exit();
+  client_exit();
 }
 
 /**************************************************************************
Index: client/gui-xaw/dialogs.c
===================================================================
--- client/gui-xaw/dialogs.c    (Revision 11417)
+++ client/gui-xaw/dialogs.c    (Arbeitskopie)
@@ -1552,7 +1552,7 @@
 void races_quit_command_callback(Widget w, XtPointer client_data, 
                                 XtPointer call_data)
 {
-  ui_exit();
+  client_exit();
 }
 
 /**************************************************************************
Index: client/include/gui_main_g.h
===================================================================
--- client/include/gui_main_g.h (Revision 11417)
+++ client/include/gui_main_g.h (Arbeitskopie)
@@ -22,6 +22,7 @@
 
 void ui_init(void);
 void ui_main(int argc, char *argv[]);
+void ui_exit(void);
 void update_conn_list_dialog(void);
 void sound_bell(void);
 void add_net_input(int);
Index: client/gui-win32/gui_main.c
===================================================================
--- client/gui-win32/gui_main.c (Revision 11417)
+++ client/gui-win32/gui_main.c (Arbeitskopie)
@@ -814,7 +814,14 @@
   FreeLibrary(hmsimg32);
 }
 
+/**************************************************************************
+  Do any necessary UI-specific cleanup
+**************************************************************************/
+void ui_exit()
+{
 
+}
+
 /**************************************************************************
  Update the connected users list at pregame state.
 **************************************************************************/
Index: client/gui-win32/menu.c
===================================================================
--- client/gui-win32/menu.c     (Revision 11417)
+++ client/gui-win32/menu.c     (Arbeitskopie)
@@ -590,7 +590,7 @@
       disconnect_from_server();
       break;
     case IDM_GAME_QUIT:
-      ui_exit();
+      client_exit();
       break;
 
 
Index: client/gui-win32/dialogs.c
===================================================================
--- client/gui-win32/dialogs.c  (Revision 11417)
+++ client/gui-win32/dialogs.c  (Arbeitskopie)
@@ -430,7 +430,7 @@
          }
          break;
        case ID_RACESDLG_QUIT:
-         ui_exit();
+         client_exit();
          break;
        case IDCANCEL:
          popdown_races_dialog();
Index: client/gui-sdl/gui_main.c
===================================================================
--- client/gui-sdl/gui_main.c   (Revision 11417)
+++ client/gui-sdl/gui_main.c   (Arbeitskopie)
@@ -68,6 +68,7 @@
 #include "messagewin.h"
 #include "optiondlg.h"
 #include "repodlgs.h"
+#include "themespec.h"
 #include "spaceshipdlg.h"
 
 #include "gui_main.h"
@@ -955,12 +956,20 @@
   gui_event_loop(NULL, NULL, main_key_down_handler, main_key_up_handler,
                 main_mouse_button_down_handler, main_mouse_button_up_handler,
                 main_mouse_motion_handler);
+                 
+}
 
-  #if defined UNDER_CE && defined SMALL_SCREEN
+/**************************************************************************
+  Do any necessary UI-specific cleanup
+**************************************************************************/
+void ui_exit()
+{
+  
+#if defined UNDER_CE && defined SMALL_SCREEN
   /* change back to window mode to restore the title bar */
   set_video_mode(320, 240, SDL_SWSURFACE | SDL_ANYFORMAT);
-  #endif
-
+#endif
+  
   free_auxiliary_tech_icons();
   
   intel_dialog_done();  
@@ -968,14 +977,13 @@
   unload_cursors();
 
   FREE(button_behavior.event);
+
+/* FIXME */  
+/*  del_main_list();*/
   
-/* FIXME: the font system cannot be freed yet, because it is still 
- * needed in civclient.c for message window output */
-#if 0 
   free_font_system();
-  del_main_list();
-#endif  
-
+  theme_free(theme);
+  
   quit_sdl();
 }
 
Index: client/clinet.c
===================================================================
--- client/clinet.c     (Revision 11417)
+++ client/clinet.c     (Arbeitskopie)
@@ -126,7 +126,7 @@
   append_output_window(_("Lost connection to server!"));
   freelog(LOG_NORMAL, "lost connection to server");
   if (with_ggz) {
-    ui_exit();
+    client_exit();
   }
 }
 
@@ -266,7 +266,7 @@
   }
   append_output_window(_("Disconnected from server."));
   if (with_ggz) {
-    ui_exit();
+    client_exit();
   }
 }  
 
Index: client/gui-stub/gui_main.c
===================================================================
--- client/gui-stub/gui_main.c  (Revision 11417)
+++ client/gui-stub/gui_main.c  (Arbeitskopie)
@@ -66,6 +66,14 @@
 }
 
 /**************************************************************************
+  Do any necessary UI-specific cleanup
+**************************************************************************/
+void ui_exit()
+{
+  /* PORTME */
+}
+
+/**************************************************************************
  Update the connected users list at pregame state.
 **************************************************************************/
 void update_conn_list_dialog(void)
Index: client/civclient.c
===================================================================
--- client/civclient.c  (Revision 11417)
+++ client/civclient.c  (Arbeitskopie)
@@ -361,7 +361,7 @@
   ui_main(argc, argv);
 
   /* termination */
-  ui_exit();
+  client_exit();
   
   /* not reached */
   return EXIT_SUCCESS;
@@ -370,7 +370,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-void ui_exit(void)
+void client_exit(void)
 {
   attribute_flush();
   client_remove_all_cli_conn();
@@ -379,13 +379,17 @@
   if (save_options_on_exit) {
     save_options();
   }
+  
   tileset_free(tileset);
+  
+  ui_exit();
+  
   control_done();
   chatline_common_done();
   message_options_free();
   client_game_free();
 
-  helpdata_done(); /* ui_exit() unlinks help text list */
+  helpdata_done(); /* client_exit() unlinks help text list */
   conn_list_free(game.all_connections);
   conn_list_free(game.est_connections);
   exit(EXIT_SUCCESS);
Index: client/civclient.h
===================================================================
--- client/civclient.h  (Revision 11417)
+++ client/civclient.h  (Arbeitskopie)
@@ -63,7 +63,7 @@
 
 void client_game_init(void);
 void client_game_free(void);
-void ui_exit(void);
+void client_exit(void);
 
 /* Set in GUI code. */
 extern const char * const gui_character_encoding;

[Prev in Thread] Current Thread [Next in Thread]