From ed91537b1f96bdd3ae5df3b69682e7baeb82dc8e Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 19 Nov 2021 17:00:40 +0200 Subject: [PATCH 26/26] gtk: Unref ref protecting widgets from destruction in editinfobox_refresh() See osdn #43222 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.0/editgui.c | 8 ++++++++ client/gui-gtk-3.0/gui_main.c | 5 +++++ client/gui-gtk-3.22/editgui.c | 8 ++++++++ client/gui-gtk-3.22/gui_main.c | 5 +++++ client/gui-gtk-4.0/editgui.c | 8 ++++++++ client/gui-gtk-4.0/gui_main.c | 5 +++++ 6 files changed, 39 insertions(+) diff --git a/client/gui-gtk-3.0/editgui.c b/client/gui-gtk-3.0/editgui.c index 5745fa20a4..1dd14f9848 100644 --- a/client/gui-gtk-3.0/editgui.c +++ b/client/gui-gtk-3.0/editgui.c @@ -1833,6 +1833,14 @@ void editgui_create_widgets(void) void editgui_free(void) { struct editbar *eb = editgui_get_editbar(); + struct editinfobox *ei = editgui_get_editinfobox(); + + if (ei != NULL) { + /* We have extra ref for ei->widget that has protected + * it from getting destroyed when editinfobox_refresh() + * moves widgets around. Free that extra ref here. */ + g_object_unref(ei->widget); + } clear_tool_stores(eb); } diff --git a/client/gui-gtk-3.0/gui_main.c b/client/gui-gtk-3.0/gui_main.c index 39378f52a1..e4388d4679 100644 --- a/client/gui-gtk-3.0/gui_main.c +++ b/client/gui-gtk-3.0/gui_main.c @@ -1828,6 +1828,11 @@ void 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(); diff --git a/client/gui-gtk-3.22/editgui.c b/client/gui-gtk-3.22/editgui.c index dd69a6f2b1..f5600ed7c9 100644 --- a/client/gui-gtk-3.22/editgui.c +++ b/client/gui-gtk-3.22/editgui.c @@ -1832,6 +1832,14 @@ void editgui_create_widgets(void) void editgui_free(void) { struct editbar *eb = editgui_get_editbar(); + struct editinfobox *ei = editgui_get_editinfobox(); + + if (ei != NULL) { + /* We have extra ref for ei->widget that has protected + * it from getting destroyed when editinfobox_refresh() + * moves widgets around. Free that extra ref here. */ + g_object_unref(ei->widget); + } clear_tool_stores(eb); } diff --git a/client/gui-gtk-3.22/gui_main.c b/client/gui-gtk-3.22/gui_main.c index a3807e9eaa..d038b749ac 100644 --- a/client/gui-gtk-3.22/gui_main.c +++ b/client/gui-gtk-3.22/gui_main.c @@ -1914,6 +1914,11 @@ void 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(); diff --git a/client/gui-gtk-4.0/editgui.c b/client/gui-gtk-4.0/editgui.c index 462775becc..f455b9013b 100644 --- a/client/gui-gtk-4.0/editgui.c +++ b/client/gui-gtk-4.0/editgui.c @@ -1879,6 +1879,14 @@ void editgui_create_widgets(void) void editgui_free(void) { struct editbar *eb = editgui_get_editbar(); + struct editinfobox *ei = editgui_get_editinfobox(); + + if (ei != NULL) { + /* We have extra ref for ei->widget that has protected + * it from getting destroyed when editinfobox_refresh() + * moves widgets around. Free that extra ref here. */ + g_object_unref(ei->widget); + } clear_tool_stores(eb); } diff --git a/client/gui-gtk-4.0/gui_main.c b/client/gui-gtk-4.0/gui_main.c index ad754f6a18..2de58bdb9c 100644 --- a/client/gui-gtk-4.0/gui_main.c +++ b/client/gui-gtk-4.0/gui_main.c @@ -1777,6 +1777,11 @@ void 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); + destroy_server_scans(); free_mapcanvas_and_overview(); spaceship_dialog_done(); -- 2.33.0