Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2002:
[Freeciv-Dev] closing dialog windows on server disconnect (PR#533)
Home

[Freeciv-Dev] closing dialog windows on server disconnect (PR#533)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] closing dialog windows on server disconnect (PR#533)
From: jdorje@xxxxxxxxxxxxxxxxxxxxx
Date: Thu, 3 Oct 2002 10:30:49 -0700 (PDT)

When the client disconnects (or is disconnected) from the server, many dialog windows are not closed. This is clearly Wrong, and can lead to segfaults - particularly in the case of the city report dialog.

The dialogs that aren't closed include everything from the reports dialog. (Some of these are modal dialogs, so you can't *manually* disconnect while they're open.) Additionally some dialogs aren't correctly updated if you disconnect and connect to a different game (for instance the players dialog won't be updated until you close it).

The attached patch fixes this for the city dialog only. It adds a new GUI function, popdown_city_report_dialog, implements this for the stub, gtk, gtk-2.0, xaw, and (untested) win32 GUIs. The function is called on server disconnect. It will, unfortunately, break compilation of the other guis (i.e. mui).

Is this the correct fix? Should a similar thing be done for the other dialogs?

jason
? debian.diff
? freeciv-1.13.1-devel.tar.gz
? freeciv-patches.tgz
? jason-game.gz
? ndebug-warning.diff
? normalize_map_pos.diff
? option_callback.diff
? popdown_city_report_dialog.diff
? rc
? server_gen_string.diff
? test.pl
? tileset_switching-3.diff
? ai/output
Index: client/clinet.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/clinet.c,v
retrieving revision 1.74
diff -u -r1.74 clinet.c
--- client/clinet.c     2002/09/17 13:09:47     1.74
+++ client/clinet.c     2002/10/03 17:23:01
@@ -64,6 +64,7 @@
 #include "hash.h"
 
 #include "chatline_g.h"
+#include "cityrep_g.h"         /* popdown_city_report_dialog() */
 #include "civclient.h"
 #include "climisc.h"
 #include "dialogs_g.h"         /* popdown_races_dialog() */
@@ -97,9 +98,11 @@
   pc->send_buffer = NULL;
 
   remove_net_input();
-  popdown_races_dialog(); 
 
+  /* Close all applicable dialog windows. */
+  popdown_races_dialog();
   reports_force_thaw();
+  popdown_city_report_dialog();
   
   set_client_state(CLIENT_PRE_GAME_STATE);
   agents_disconnect();
Index: client/gui-gtk/cityrep.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/cityrep.c,v
retrieving revision 1.64
diff -u -r1.64 cityrep.c
--- client/gui-gtk/cityrep.c    2002/09/25 20:24:51     1.64
+++ client/gui-gtk/cityrep.c    2002/10/03 17:23:03
@@ -1157,11 +1157,20 @@
 *****************************************************************/
 static void city_close_callback(GtkWidget *w, gpointer data)
 {
+  popdown_city_report_dialog();
+}
 
-  if(city_dialog_shell_is_modal)
-     gtk_widget_set_sensitive(top_vbox, TRUE);
-   gtk_widget_destroy(city_dialog_shell);
-   city_dialog_shell=NULL;
+
+/****************************************************************
+  Call this function to close the city report dialog.
+*****************************************************************/
+void popdown_city_report_dialog(void)
+{
+  if (city_dialog_shell_is_modal) {
+    gtk_widget_set_sensitive(top_vbox, TRUE);
+  }
+  gtk_widget_destroy(city_dialog_shell);
+  city_dialog_shell = NULL;
 }
 
 /****************************************************************
Index: client/gui-gtk-2.0/cityrep.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/cityrep.c,v
retrieving revision 1.26
diff -u -r1.26 cityrep.c
--- client/gui-gtk-2.0/cityrep.c        2002/09/27 15:46:59     1.26
+++ client/gui-gtk-2.0/cityrep.c        2002/10/03 17:23:04
@@ -139,6 +139,14 @@
   gtk_window_present(GTK_WINDOW(city_dialog_shell));
 }
 
+/****************************************************************
+  Call this function to close the city report dialog.
+*****************************************************************/
+void popdown_city_report_dialog(void)
+{
+   gtk_widget_destroy(city_dialog_shell);
+   city_dialog_shell = NULL;
+}
 
 /****************************************************************
 ...
Index: client/gui-stub/cityrep.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-stub/cityrep.c,v
retrieving revision 1.2
diff -u -r1.2 cityrep.c
--- client/gui-stub/cityrep.c   2002/03/17 10:49:00     1.2
+++ client/gui-stub/cityrep.c   2002/10/03 17:23:04
@@ -11,6 +11,14 @@
        /* PORTME */
 }
 
+/****************************************************************
+  Call this function to close the city report dialog.
+*****************************************************************/
+void popdown_city_report_dialog(void)
+{
+  /* PORTME */
+}
+
 void
 city_report_dialog_update(void)
 {
Index: client/gui-win32/cityrep.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/cityrep.c,v
retrieving revision 1.16
diff -u -r1.16 cityrep.c
--- client/gui-win32/cityrep.c  2002/09/25 20:24:53     1.16
+++ client/gui-win32/cityrep.c  2002/10/03 17:23:05
@@ -991,7 +991,7 @@
        {
          
        case ID_CITYREP_CLOSE:
-         DestroyWindow(hCityRep);
+         popdown_city_report_dialog();
          break;
        case ID_CITYREP_LIST:
          selcount=ListBox_GetSelCount(GetDlgItem(hWnd,ID_CITYREP_LIST));
@@ -1069,7 +1069,7 @@
        }
       break;
     case WM_CLOSE:
-      DestroyWindow(hCityRep);      
+      popdown_city_report_dialog();
       break;
     default:
       return DefWindowProc(hWnd,uMsg,wParam,lParam);
@@ -1097,6 +1097,16 @@
   hChangeAll=NULL;
   city_report_dialog_update();
   ShowWindow(hCityRep,SW_SHOWNORMAL);
+}
+
+/****************************************************************
+  Call this function to close the city report dialog.
+*****************************************************************/
+void popdown_city_report_dialog(void)
+{
+  if (hCityRep) {
+    DestroyWindow(hCityRep);
+  }
 }
 
 /**************************************************************************
Index: client/gui-xaw/cityrep.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/cityrep.c,v
retrieving revision 1.44
diff -u -r1.44 cityrep.c
--- client/gui-xaw/cityrep.c    2002/09/25 20:24:53     1.44
+++ client/gui-xaw/cityrep.c    2002/10/03 17:23:07
@@ -459,6 +459,14 @@
 void city_close_callback(Widget w, XtPointer client_data, 
                         XtPointer call_data)
 {
+  popdown_city_report_dialog();
+}
+
+/****************************************************************
+  Call this function to close the city report dialog.
+*****************************************************************/
+void popdown_city_report_dialog(void)
+{
   if(city_dialog_shell_is_modal)
      XtSetSensitive(main_form, TRUE);
   XtDestroyWidget(city_dialog_shell);
Index: client/include/cityrep_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/cityrep_g.h,v
retrieving revision 1.4
diff -u -r1.4 cityrep_g.h
--- client/include/cityrep_g.h  2002/04/12 13:50:55     1.4
+++ client/include/cityrep_g.h  2002/10/03 17:23:07
@@ -18,6 +18,7 @@
 struct city;
 
 void popup_city_report_dialog(bool make_modal);
+void popdown_city_report_dialog(void);
 void city_report_dialog_update(void);
 void city_report_dialog_update_city(struct city *pcity);
 

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