From e51843ea978ec04692ea64c78c71e852d67a62b3 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 27 Nov 2021 15:10:09 +0200 Subject: [PATCH 39/39] gtk3x: Replace gtk_widget_destroyed() uses with new widget_destroyed() gtk-3.98.4 drops gtk_widget_destroyed(). Implement and use our own widget_destroyed() instead. See osdn #43285 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/dialogs.c | 8 ++++---- client/gui-gtk-4.0/gamedlgs.c | 6 +++--- client/gui-gtk-4.0/gotodlg.c | 2 +- client/gui-gtk-4.0/gui_main.c | 4 ++-- client/gui-gtk-4.0/gui_stuff.c | 8 ++++++++ client/gui-gtk-4.0/gui_stuff.h | 1 + client/gui-gtk-4.0/luaconsole.c | 4 ++-- client/gui-gtk-4.0/pages.c | 6 +++--- 8 files changed, 24 insertions(+), 15 deletions(-) diff --git a/client/gui-gtk-4.0/dialogs.c b/client/gui-gtk-4.0/dialogs.c index 296197ed74..65ac7fec21 100644 --- a/client/gui-gtk-4.0/dialogs.c +++ b/client/gui-gtk-4.0/dialogs.c @@ -292,7 +292,7 @@ void popup_revolution_dialog(struct government *government) setup_dialog(shell, toplevel); g_signal_connect(shell, "destroy", - G_CALLBACK(gtk_widget_destroyed), &shell); + G_CALLBACK(widget_destroyed), &shell); } g_signal_connect(shell, "response", G_CALLBACK(revolution_response), government); @@ -985,7 +985,7 @@ static void create_races_dialog(struct player *pplayer) gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(nationsets_chooser), renderer, "markup", 1, NULL); g_signal_connect(nationsets_chooser, "destroy", - G_CALLBACK(gtk_widget_destroyed), &nationsets_chooser); + G_CALLBACK(widget_destroyed), &nationsets_chooser); g_signal_connect(nationsets_chooser, "changed", G_CALLBACK(nationset_callback), NULL); { @@ -1059,7 +1059,7 @@ static void create_races_dialog(struct player *pplayer) races_properties = table = gtk_grid_new(); g_signal_connect(table, "destroy", - G_CALLBACK(gtk_widget_destroyed), &races_properties); + G_CALLBACK(widget_destroyed), &races_properties); g_object_set(table, "margin", 6, NULL); gtk_grid_set_row_spacing(GTK_GRID(table), 2); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label); @@ -1175,7 +1175,7 @@ static void create_races_dialog(struct player *pplayer) /* Signals. */ g_signal_connect(shell, "destroy", - G_CALLBACK(gtk_widget_destroyed), &races_shell); + G_CALLBACK(widget_destroyed), &races_shell); g_signal_connect(shell, "response", G_CALLBACK(races_response), NULL); diff --git a/client/gui-gtk-4.0/gamedlgs.c b/client/gui-gtk-4.0/gamedlgs.c index 31fe92c59b..59e209c78b 100644 --- a/client/gui-gtk-4.0/gamedlgs.c +++ b/client/gui-gtk-4.0/gamedlgs.c @@ -352,7 +352,7 @@ static GtkWidget *create_multiplier_dialog(void) g_signal_connect(multipliers_scale[multiplier], "format-value", G_CALLBACK(multiplier_value_callback), pmul); g_signal_connect(multipliers_scale[multiplier], "destroy", - G_CALLBACK(gtk_widget_destroyed), + G_CALLBACK(widget_destroyed), &multipliers_scale[multiplier]); gtk_box_insert_child_after(GTK_BOX(content), label, NULL); gtk_box_insert_child_after(GTK_BOX(content), scale, NULL); @@ -364,7 +364,7 @@ static GtkWidget *create_multiplier_dialog(void) multiplier_dialog_update_values(TRUE); g_signal_connect(shell, "destroy", - G_CALLBACK(gtk_widget_destroyed), &multiplier_dialog_shell); + G_CALLBACK(widget_destroyed), &multiplier_dialog_shell); g_signal_connect(shell, "response", G_CALLBACK(multipliers_command_callback), NULL); @@ -499,7 +499,7 @@ static GtkWidget *create_rates_dialog(void) g_signal_connect(shell, "response", G_CALLBACK(rates_command_callback), NULL); g_signal_connect(shell, "destroy", - G_CALLBACK(gtk_widget_destroyed), &rates_dialog_shell); + G_CALLBACK(widget_destroyed), &rates_dialog_shell); gtk_widget_show(shell); diff --git a/client/gui-gtk-4.0/gotodlg.c b/client/gui-gtk-4.0/gotodlg.c index 87b2beef4a..c27da93165 100644 --- a/client/gui-gtk-4.0/gotodlg.c +++ b/client/gui-gtk-4.0/gotodlg.c @@ -151,7 +151,7 @@ static void create_goto_dialog(void) setup_dialog(dshell, toplevel); gtk_dialog_set_default_response(GTK_DIALOG(dshell), CMD_GOTO); g_signal_connect(dshell, "destroy", - G_CALLBACK(gtk_widget_destroyed), &dshell); + G_CALLBACK(widget_destroyed), &dshell); g_signal_connect(dshell, "response", G_CALLBACK(goto_cmd_callback), NULL); diff --git a/client/gui-gtk-4.0/gui_main.c b/client/gui-gtk-4.0/gui_main.c index c1e6276deb..004d57ff10 100644 --- a/client/gui-gtk-4.0/gui_main.c +++ b/client/gui-gtk-4.0/gui_main.c @@ -2239,9 +2239,9 @@ void popup_quit_dialog(void) setup_dialog(dialog, toplevel); g_signal_connect(dialog, "response", - G_CALLBACK(quit_dialog_response), NULL); + G_CALLBACK(quit_dialog_response), NULL); g_signal_connect(dialog, "destroy", - G_CALLBACK(gtk_widget_destroyed), &dialog); + G_CALLBACK(widget_destroyed), &dialog); } gtk_window_present(GTK_WINDOW(dialog)); diff --git a/client/gui-gtk-4.0/gui_stuff.c b/client/gui-gtk-4.0/gui_stuff.c index da7d73dc3c..7d414d16f4 100644 --- a/client/gui-gtk-4.0/gui_stuff.c +++ b/client/gui-gtk-4.0/gui_stuff.c @@ -1185,3 +1185,11 @@ gint blocking_dialog(GtkWidget *dlg) return data.response; } + +/**********************************************************************//** + Nullify GtkWidget pointer when widget is destroyed +**************************************************************************/ +void widget_destroyed(GtkWidget *wdg, void *data) +{ + *(GtkWidget **)data = NULL; +} diff --git a/client/gui-gtk-4.0/gui_stuff.h b/client/gui-gtk-4.0/gui_stuff.h index 01d0645db4..12541d2872 100644 --- a/client/gui-gtk-4.0/gui_stuff.h +++ b/client/gui-gtk-4.0/gui_stuff.h @@ -137,5 +137,6 @@ void disable_gobject_callback(GObject *obj, GCallback cb); void enable_gobject_callback(GObject *obj, GCallback cb); gint blocking_dialog(GtkWidget *dlg); +void widget_destroyed(GtkWidget *wdg, void *data); #endif /* FC__GUI_STUFF_H */ diff --git a/client/gui-gtk-4.0/luaconsole.c b/client/gui-gtk-4.0/luaconsole.c index bfdcc9b9a7..eeee0beb83 100644 --- a/client/gui-gtk-4.0/luaconsole.c +++ b/client/gui-gtk-4.0/luaconsole.c @@ -221,7 +221,7 @@ static void luaconsole_dialog_create(struct luaconsole_data *pdialog) gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5); pdialog->message_area = GTK_TEXT_VIEW(text); - g_signal_connect(text, "destroy", G_CALLBACK(gtk_widget_destroyed), + g_signal_connect(text, "destroy", G_CALLBACK(widget_destroyed), &pdialog->message_area); /* The lua console input line. */ @@ -233,7 +233,7 @@ static void luaconsole_dialog_create(struct luaconsole_data *pdialog) g_signal_connect(entry, "key_press_event", G_CALLBACK(luaconsole_input_handler), NULL); pdialog->entry = entry; - g_signal_connect(entry, "destroy", G_CALLBACK(gtk_widget_destroyed), + g_signal_connect(entry, "destroy", G_CALLBACK(widget_destroyed), &pdialog->entry); /* Load lua script command button. */ diff --git a/client/gui-gtk-4.0/pages.c b/client/gui-gtk-4.0/pages.c index a7eceb058a..20a5af9b9b 100644 --- a/client/gui-gtk-4.0/pages.c +++ b/client/gui-gtk-4.0/pages.c @@ -3498,7 +3498,7 @@ void save_game_dialog_popup(void) shell = save_dialog_new(_("Save Game"), _("Saved _Games:"), _("Save _Filename:"), send_save_game, save_dialog_savegame_list); - g_signal_connect(shell, "destroy", G_CALLBACK(gtk_widget_destroyed), + g_signal_connect(shell, "destroy", G_CALLBACK(widget_destroyed), &shell); gtk_window_present(GTK_WINDOW(shell)); } @@ -3533,7 +3533,7 @@ void save_scenario_dialog_popup(void) shell = save_dialog_new(_("Save Scenario"), _("Saved Sce_narios:"), _("Save Sc_enario:"), save_dialog_save_scenario, save_dialog_scenario_list); - g_signal_connect(shell, "destroy", G_CALLBACK(gtk_widget_destroyed), + g_signal_connect(shell, "destroy", G_CALLBACK(widget_destroyed), &shell); gtk_window_present(GTK_WINDOW(shell)); } @@ -3562,7 +3562,7 @@ void save_mapimg_dialog_popup(void) shell = save_dialog_new(_("Save Map Image"), _("Saved Map _Images:"), _("Save _Map Images:"), mapimg_client_save, save_dialog_mapimg_list); - g_signal_connect(shell, "destroy", G_CALLBACK(gtk_widget_destroyed), + g_signal_connect(shell, "destroy", G_CALLBACK(widget_destroyed), &shell); gtk_window_present(GTK_WINDOW(shell)); } -- 2.33.0