From 1752c7528022ffdf248e8f7bf9434fbaebcf9f99 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 9 Jun 2023 21:07:11 +0300 Subject: [PATCH 42/42] 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-3.22/gui_main.c | 11 ++++++----- client/gui-gtk-4.0/gui_main.c | 17 +++++++++-------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/client/gui-gtk-3.22/gui_main.c b/client/gui-gtk-3.22/gui_main.c index d13e9e75ca..10292b7ba2 100644 --- a/client/gui-gtk-3.22/gui_main.c +++ b/client/gui-gtk-3.22/gui_main.c @@ -2046,11 +2046,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(); @@ -2061,6 +2056,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-4.0/gui_main.c b/client/gui-gtk-4.0/gui_main.c index 92ab4db0f8..e730326569 100644 --- a/client/gui-gtk-4.0/gui_main.c +++ b/client/gui-gtk-4.0/gui_main.c @@ -1927,14 +1927,6 @@ int ui_main(int argc, char **argv) g_application_run(G_APPLICATION(fc_app), 0, NULL); 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); - if (empty_unit_paintable != NULL) { - g_object_unref(empty_unit_paintable); - } - destroy_server_scans(); free_mapcanvas_and_overview(); spaceship_dialog_done(); @@ -1945,6 +1937,15 @@ 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); + if (empty_unit_paintable != NULL) { + g_object_unref(empty_unit_paintable); + } + editgui_free(); gtk_window_destroy(GTK_WINDOW(toplevel)); message_buffer = NULL; /* Result of destruction of everything */ -- 2.39.2