From a2b951860f676a2b6cc6e8164e471efc9235ffdc Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 9 Jun 2023 21:07:11 +0300 Subject: [PATCH 22/22] 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.0/gui_main.c | 11 ++++++----- client/gui-gtk-3.22/gui_main.c | 11 ++++++----- client/gui-gtk-4.0/gui_main.c | 17 +++++++++-------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/client/gui-gtk-3.0/gui_main.c b/client/gui-gtk-3.0/gui_main.c index da99fdc4ca..6ddfcf7058 100644 --- a/client/gui-gtk-3.0/gui_main.c +++ b/client/gui-gtk-3.0/gui_main.c @@ -1829,11 +1829,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(); @@ -1844,6 +1839,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 f28a31069c..847c5806c6 100644 --- a/client/gui-gtk-3.22/gui_main.c +++ b/client/gui-gtk-3.22/gui_main.c @@ -1986,11 +1986,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(); @@ -2001,6 +1996,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 446038f261..04c16b9549 100644 --- a/client/gui-gtk-4.0/gui_main.c +++ b/client/gui-gtk-4.0/gui_main.c @@ -1870,14 +1870,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(); @@ -1888,6 +1880,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