From d6d2a434667023a632f470124cdaad0722c55f41 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 2 Nov 2022 02:52:53 +0200 Subject: [PATCH 21/21] 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 6a9f3ba21c..2106752d66 100644 --- a/client/gui-sdl2/citydlg.c +++ b/client/gui-sdl2/citydlg.c @@ -1687,23 +1687,21 @@ static int next_prev_city_dlg_callback(struct widget *pButton) } /************************************************************************** - Rename city name: + New city name given for renaming it. **************************************************************************/ static int new_name_city_dlg_callback(struct widget *pEdit) { - if (PRESSED_EVENT(Main.event)) { - if (pEdit->string_utf8->text != NULL) { - if (strcmp(pEdit->string_utf8->text, city_name_get(pCityDlg->pCity))) { - SDL_Client_Flags |= CF_CHANGED_CITY_NAME; - city_rename(pCityDlg->pCity, pEdit->string_utf8->text); - } - } else { - /* empty input -> restore previous content */ - copy_chars_to_utf8_str(pEdit->string_utf8, city_name_get(pCityDlg->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(pCityDlg->pCity))) { + SDL_Client_Flags |= CF_CHANGED_CITY_NAME; + city_rename(pCityDlg->pCity, pEdit->string_utf8->text); } + } else { + /* Empty input -> restore previous content */ + copy_chars_to_utf8_str(pEdit->string_utf8, city_name_get(pCityDlg->pCity)); + widget_redraw(pEdit); + widget_mark_dirty(pEdit); + flush_dirty(); } return -1; -- 2.35.1