<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40516 >
It is possible to crash the client if a user detaches or observes then clicks on the "Take Player" button, selects a nation, and presses "Ok". Attached patch fixes this for S2_1. The S2_2/trunk version also fixes the conditions for picking a nation and the bad call to popup_races_dialog. The design is that the "Pick Nation" button only applies to the player you are controlling; to edit other players' nations you use the right-click menu in the connection list. ----------------------------------------------------------------------- 手短にいうと、地獄から来た悪魔だった。
diff --git a/client/gui-gtk-2.0/dialogs.c b/client/gui-gtk-2.0/dialogs.c index 620c04c..7f0aa24 100644 --- a/client/gui-gtk-2.0/dialogs.c +++ b/client/gui-gtk-2.0/dialogs.c @@ -989,6 +989,10 @@ static void create_races_dialog(struct player *pplayer) *****************************************************************/ void popup_races_dialog(struct player *pplayer) { + if (!pplayer) { + return; + } + if (!races_shell) { create_races_dialog(pplayer); gtk_window_present(GTK_WINDOW(races_shell)); diff --git a/client/gui-gtk-2.0/gui_main.c b/client/gui-gtk-2.0/gui_main.c index 1ed2e8b..ca5cb1e 100644 --- a/client/gui-gtk-2.0/gui_main.c +++ b/client/gui-gtk-2.0/gui_main.c @@ -1647,10 +1647,9 @@ void update_conn_list_dialog(void) /* Nation button will go to Nation selection */ gtk_stockbutton_set_label(nation_button, _("Pick _Nation")); - /* Sensitive iff client can select nation. - * FIXME: Observer can always select nations? */ - gtk_widget_set_sensitive(nation_button, game.info.is_new_game); - /* && can_client_control()); */ + /* Sensitive iff client is controlling a player. */ + gtk_widget_set_sensitive(nation_button, game.info.is_new_game + && can_client_control()); } if (!client_is_observer()) { diff --git a/client/gui-gtk-2.0/pages.c b/client/gui-gtk-2.0/pages.c index 347f886..640c212 100644 --- a/client/gui-gtk-2.0/pages.c +++ b/client/gui-gtk-2.0/pages.c @@ -988,11 +988,10 @@ static void start_start_callback(GtkWidget *w, gpointer data) **************************************************************************/ static void pick_nation_callback(GtkWidget *w, gpointer data) { - if (NULL != client.conn.playing) { - popup_races_dialog(client.conn.playing); + if (can_client_control()) { + popup_races_dialog(client_player()); } else if (game.info.is_new_game) { send_chat("/take -"); - popup_races_dialog(NULL); } }
diff --git a/client/gui-gtk-2.0/dialogs.c b/client/gui-gtk-2.0/dialogs.c index 854ce00..a4da319 100644 --- a/client/gui-gtk-2.0/dialogs.c +++ b/client/gui-gtk-2.0/dialogs.c @@ -952,6 +952,10 @@ static void create_races_dialog(struct player *pplayer) *****************************************************************/ void popup_races_dialog(struct player *pplayer) { + if (!pplayer) { + return; + } + if (!races_shell) { create_races_dialog(pplayer); gtk_window_present(GTK_WINDOW(races_shell));
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev