From 0c3bba64f77fa6dcce558e2c199074d558aaf7c1 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 2 Nov 2022 02:45:22 +0200 Subject: [PATCH 50/50] sdl2: Fix city rename to take effect See osdn #45986 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/citydlg.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/client/gui-sdl2/citydlg.c b/client/gui-sdl2/citydlg.c index ec5ea3b7dc..29f68b814a 100644 --- a/client/gui-sdl2/citydlg.c +++ b/client/gui-sdl2/citydlg.c @@ -1717,23 +1717,21 @@ static int next_prev_city_dlg_callback(struct widget *button) } /**********************************************************************//** - Rename city name: + New city name given for renaming it. **************************************************************************/ static int new_name_city_dlg_callback(struct widget *pedit) { - if (PRESSED_EVENT(main_data.event)) { - if (pedit->string_utf8->text != NULL) { - if (strcmp(pedit->string_utf8->text, city_name_get(pcity_dlg->pcity))) { - sdl2_client_flags |= CF_CHANGED_CITY_NAME; - city_rename(pcity_dlg->pcity, pedit->string_utf8->text); - } - } else { - /* empty input -> restore previous content */ - copy_chars_to_utf8_str(pedit->string_utf8, city_name_get(pcity_dlg->pcity)); - widget_redraw(pedit); - widget_mark_dirty(pedit); - flush_dirty(); + if (pedit->string_utf8->text != NULL) { + if (strcmp(pedit->string_utf8->text, city_name_get(pcity_dlg->pcity))) { + sdl2_client_flags |= CF_CHANGED_CITY_NAME; + city_rename(pcity_dlg->pcity, pedit->string_utf8->text); } + } else { + /* Empty input -> restore previous content */ + copy_chars_to_utf8_str(pedit->string_utf8, city_name_get(pcity_dlg->pcity)); + widget_redraw(pedit); + widget_mark_dirty(pedit); + flush_dirty(); } return -1; -- 2.35.1