From 545921c5d45b7c6ce22e9ed7da7c4cfc235e311c Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 23 Oct 2022 18:56:58 +0300 Subject: [PATCH 52/52] Qt: Popdown old tile info before popping up new one The old code resulted in such old popups staying up forever after the new popup overwrote the only pointer we have towards them. Reported by ddeanbrown See osdn #44177 Signed-off-by: Marko Lindqvist --- client/gui-qt/fc_client.cpp | 2 +- client/gui-qt/mapctrl.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/gui-qt/fc_client.cpp b/client/gui-qt/fc_client.cpp index b0c4b6d309..a4dd46e756 100644 --- a/client/gui-qt/fc_client.cpp +++ b/client/gui-qt/fc_client.cpp @@ -112,7 +112,7 @@ fc_client::fc_client() : QMainWindow() game_tab_widget = NULL; start_players_tree = NULL; unit_sel = NULL; - info_tile_wdg = NULL; + info_tile_wdg = nullptr; opened_dialog = NULL; current_file = ""; status_bar_queue.clear(); diff --git a/client/gui-qt/mapctrl.cpp b/client/gui-qt/mapctrl.cpp index c3d8f57433..9d40b015ce 100644 --- a/client/gui-qt/mapctrl.cpp +++ b/client/gui-qt/mapctrl.cpp @@ -547,7 +547,10 @@ void fc_client::popup_tile_info(struct tile *ptile) { struct unit *punit = NULL; - Q_ASSERT(info_tile_wdg == NULL); + if (info_tile_wdg != nullptr) { + popdown_tile_info(); + } + if (TILE_UNKNOWN != client_tile_get_known(ptile)) { mapdeco_set_crosshair(ptile, true); punit = find_visible_unit(ptile); @@ -569,9 +572,9 @@ void fc_client::popdown_tile_info() { mapdeco_clear_crosshairs(); mapdeco_clear_gotoroutes(); - if (info_tile_wdg != NULL) { + if (info_tile_wdg != nullptr) { info_tile_wdg->close(); delete info_tile_wdg; - info_tile_wdg = NULL; + info_tile_wdg = nullptr; } } -- 2.35.1