summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-09-23 20:12:13 +0000
committerrubidium <rubidium@openttd.org>2008-09-23 20:12:13 +0000
commitf54f161bfb3acec2543ba414d2a34a3d8590d7ae (patch)
tree6a7491511d87a7a50c869f074dfc0ebfc48ba675
parent9246ff28ac9007ee2c3d2825c0942e624485387d (diff)
downloadopenttd-f54f161bfb3acec2543ba414d2a34a3d8590d7ae.tar.xz
(svn r14393) -Fix [FS#2318]: deleting the same window (pointer) twice.
-rw-r--r--src/signs_gui.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index f687e54c9..496444a87 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -171,10 +171,18 @@ void ShowSignList()
AllocateWindowDescFront<SignListWindow>(&_sign_list_desc, 0);
}
-static void RenameSign(SignID index, const char *text)
+/**
+ * Actually rename the sign.
+ * @param index the sign to rename.
+ * @param text the new name.
+ * @return true if the window will already be removed after returning.
+ */
+static bool RenameSign(SignID index, const char *text)
{
+ bool remove = StrEmpty(text);
_cmd_text = text;
DoCommandP(0, index, 0, NULL, CMD_RENAME_SIGN | (StrEmpty(text) ? CMD_MSG(STR_CAN_T_DELETE_SIGN) : CMD_MSG(STR_280C_CAN_T_CHANGE_SIGN_NAME)));
+ return remove;
}
enum QueryEditSignWidgets {
@@ -288,7 +296,7 @@ struct SignWindow : QueryStringBaseWindow, SignList {
break;
case QUERY_EDIT_SIGN_WIDGET_OK:
- RenameSign(this->cur_sign, this->text.buf);
+ if (RenameSign(this->cur_sign, this->text.buf)) break;
/* FALL THROUGH */
case QUERY_EDIT_SIGN_WIDGET_CANCEL:
@@ -302,7 +310,7 @@ struct SignWindow : QueryStringBaseWindow, SignList {
EventState state = ES_NOT_HANDLED;
switch (this->HandleEditBoxKey(QUERY_EDIT_SIGN_WIDGET_TEXT, key, keycode, state)) {
case 1: // Enter pressed, confirms change
- RenameSign(this->cur_sign, this->text.buf);
+ if (RenameSign(this->cur_sign, this->text.buf)) break;
/* FALL THROUGH */
case 2: // ESC pressed, closes window, abandons changes