diff options
author | smatz <smatz@openttd.org> | 2008-09-16 19:05:38 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-09-16 19:05:38 +0000 |
commit | b5fe06f43082608fd41d7fa15b18151e5f8823f4 (patch) | |
tree | ad34d1c34ba491ff9a432b22a6c686dcd3d6b3e9 | |
parent | cb16b68474c7d5becadfc950cbddc2008f567b47 (diff) | |
download | openttd-b5fe06f43082608fd41d7fa15b18151e5f8823f4.tar.xz |
(svn r14345) -Fix: delete the RenameSignWindow when 'its' sign is deleted
Also, it makes sure the RenameSignWindow isn't open when there are no signs (and crashes associted with that)
-rw-r--r-- | src/signs.cpp | 4 | ||||
-rw-r--r-- | src/signs_func.h | 1 | ||||
-rw-r--r-- | src/signs_gui.cpp | 12 |
3 files changed, 15 insertions, 2 deletions
diff --git a/src/signs.cpp b/src/signs.cpp index a2d3141b5..a9827c015 100644 --- a/src/signs.cpp +++ b/src/signs.cpp @@ -36,6 +36,10 @@ Sign::Sign(PlayerID owner) Sign::~Sign() { free(this->name); + + if (CleaningPool()) return; + + DeleteRenameSignWindow(this->index); this->owner = INVALID_PLAYER; } diff --git a/src/signs_func.h b/src/signs_func.h index 34267a882..44a3237d2 100644 --- a/src/signs_func.h +++ b/src/signs_func.h @@ -15,6 +15,7 @@ void PlaceProc_Sign(TileIndex tile); /* signs_gui.cpp */ void ShowRenameSignWindow(const Sign *si); void HandleClickOnSign(const Sign *si); +void DeleteRenameSignWindow(SignID sign); void ShowSignList(); diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index ec89f5ebc..8b319a721 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -286,8 +286,9 @@ struct SignWindow : QueryStringBaseWindow, SignList { case QUERY_EDIT_SIGN_WIDGET_DELETE: /* Only need to set the buffer to null, the rest is handled as the OK button */ - DeleteTextBufferAll(&this->text); - /* FALL THROUGH */ + RenameSign(this->cur_sign, ""); + /* don't delete this, we are deleted in Sign::~Sign() -> DeleteRenameSignWindow() */ + break; case QUERY_EDIT_SIGN_WIDGET_OK: RenameSign(this->cur_sign, this->text.buf); @@ -358,3 +359,10 @@ void ShowRenameSignWindow(const Sign *si) new SignWindow(&_query_sign_edit_desc, si); } + +void DeleteRenameSignWindow(SignID sign) +{ + SignWindow *w = dynamic_cast<SignWindow *>(FindWindowById(WC_QUERY_STRING, 0)); + + if (w != NULL && w->cur_sign == sign) delete w; +} |