tFix for GTK+ client opening multiple high score dialogs - vaccinewars - be a doctor and try to vaccinate the world
(HTM) git clone git://src.adamsgaard.dk/vaccinewars
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 1daa175d87470250d9ffc2ff2f449221d184262c
(DIR) parent 3bef9f814962b5ded538a1b2fa67a5a3bce1dcf9
(HTM) Author: Ben Webb <ben@salilab.org>
Date: Mon, 10 Sep 2001 19:28:02 +0000
Fix for GTK+ client opening multiple high score dialogs
Diffstat:
M src/gtk_client.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/src/gtk_client.c b/src/gtk_client.c
t@@ -431,12 +431,16 @@ void HandleClientMessage(char *pt,Player *Play) {
struct HiScoreDiaStruct {
GtkWidget *dialog,*table,*vbox;
};
-static struct HiScoreDiaStruct HiScoreDialog;
+static struct HiScoreDiaStruct HiScoreDialog = { NULL,NULL,NULL };
void PrepareHighScoreDialog(void) {
/* Creates an empty dialog to display high scores */
GtkWidget *dialog,*vbox,*hsep,*table;
+/* Make sure the server doesn't fool us into creating
+ multiple dialogs */
+ if (HiScoreDialog.dialog) return;
+
HiScoreDialog.dialog=dialog=gtk_window_new(GTK_WINDOW_DIALOG);
/* Title of the GTK+ high score dialog */
t@@ -469,6 +473,8 @@ void AddScoreToDialog(char *Data) {
int index,slen;
gboolean bold;
+ if (!HiScoreDialog.dialog) return;
+
cp=Data;
index=GetNextInt(&cp,0);
if (!cp || strlen(cp)<3) return;
t@@ -556,6 +562,8 @@ void CompleteHighScoreDialog(gboolean AtEnd) {
GtkWidget *OKButton,*dialog;
dialog=HiScoreDialog.dialog;
+ if (!HiScoreDialog.dialog) return;
+
/* Caption of the "OK" button in dialogs */
OKButton=gtk_button_new_with_label(_("OK"));
gtk_signal_connect_object(GTK_OBJECT(OKButton),"clicked",
t@@ -571,6 +579,9 @@ void CompleteHighScoreDialog(gboolean AtEnd) {
GTK_WIDGET_SET_FLAGS(OKButton,GTK_CAN_DEFAULT);
gtk_widget_grab_default(OKButton);
gtk_widget_show(OKButton);
+
+/* OK, we're done - allow the creation of new high score dialogs */
+ HiScoreDialog.dialog=NULL;
}
void PrintMessage(char *text) {