From 4dab7f808c07ff87987c9bbffdc5d732faef1dcf Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 9 Jun 2023 21:11:30 +0300 Subject: [PATCH 18/18] gtk: Destroy widgets in correct order in shutdown If editor mode was active at the time client closes, some widgets got destroyed too early, other parts of the code still relying on them. See osdn #45570 Signed-off-by: Marko Lindqvist --- client/gui-gtk-2.0/gui_main.c | 11 ++++++----- client/gui-gtk-3.0/gui_main.c | 11 ++++++----- client/gui-gtk-3.22/gui_main.c | 11 ++++++----- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/client/gui-gtk-2.0/gui_main.c b/client/gui-gtk-2.0/gui_main.c index a5b5c1b18e..5ed44a6917 100644 --- a/client/gui-gtk-2.0/gui_main.c +++ b/client/gui-gtk-2.0/gui_main.c @@ -1716,11 +1716,6 @@ int ui_main(int argc, char **argv) gtk_main(); gui_up = FALSE; - /* We have extra ref for unit_info_box that has protected - * it from getting destroyed when editinfobox_refresh() - * moves widgets around. Free that extra ref here. */ - g_object_unref(unit_info_box); - destroy_server_scans(); free_mapcanvas_and_overview(); spaceship_dialog_done(); @@ -1731,6 +1726,12 @@ int ui_main(int argc, char **argv) diplomacy_dialog_done(); cma_fe_done(); free_unit_table(); + + /* We have extra ref for unit_info_box that has protected + * it from getting destroyed when editinfobox_refresh() + * moves widgets around. Free that extra ref here. */ + g_object_unref(unit_info_box); + editgui_free(); gtk_widget_destroy(toplevel_tabs); gtk_widget_destroy(toplevel); diff --git a/client/gui-gtk-3.0/gui_main.c b/client/gui-gtk-3.0/gui_main.c index 6802003151..4e4117390e 100644 --- a/client/gui-gtk-3.0/gui_main.c +++ b/client/gui-gtk-3.0/gui_main.c @@ -1811,11 +1811,6 @@ int ui_main(int argc, char **argv) gtk_main(); gui_up = FALSE; - /* We have extra ref for unit_info_box that has protected - * it from getting destroyed when editinfobox_refresh() - * moves widgets around. Free that extra ref here. */ - g_object_unref(unit_info_box); - destroy_server_scans(); free_mapcanvas_and_overview(); spaceship_dialog_done(); @@ -1826,6 +1821,12 @@ int ui_main(int argc, char **argv) diplomacy_dialog_done(); cma_fe_done(); free_unit_table(); + + /* We have extra ref for unit_info_box that has protected + * it from getting destroyed when editinfobox_refresh() + * moves widgets around. Free that extra ref here. */ + g_object_unref(unit_info_box); + editgui_free(); gtk_widget_destroy(toplevel_tabs); gtk_widget_destroy(toplevel); diff --git a/client/gui-gtk-3.22/gui_main.c b/client/gui-gtk-3.22/gui_main.c index 996be76c5c..d6913640fd 100644 --- a/client/gui-gtk-3.22/gui_main.c +++ b/client/gui-gtk-3.22/gui_main.c @@ -1894,11 +1894,6 @@ int ui_main(int argc, char **argv) gtk_main(); gui_up = FALSE; - /* We have extra ref for unit_info_box that has protected - * it from getting destroyed when editinfobox_refresh() - * moves widgets around. Free that extra ref here. */ - g_object_unref(unit_info_box); - destroy_server_scans(); free_mapcanvas_and_overview(); spaceship_dialog_done(); @@ -1909,6 +1904,12 @@ int ui_main(int argc, char **argv) diplomacy_dialog_done(); cma_fe_done(); free_unit_table(); + + /* We have extra ref for unit_info_box that has protected + * it from getting destroyed when editinfobox_refresh() + * moves widgets around. Free that extra ref here. */ + g_object_unref(unit_info_box); + editgui_free(); gtk_widget_destroy(toplevel_tabs); gtk_widget_destroy(toplevel); -- 2.39.2