mirror of https://github.com/OpenTTD/OpenTTD
(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)release/0.7
parent
4a97033e7e
commit
5a1203963f
|
@ -36,6 +36,10 @@ Sign::Sign(PlayerID owner)
|
||||||
Sign::~Sign()
|
Sign::~Sign()
|
||||||
{
|
{
|
||||||
free(this->name);
|
free(this->name);
|
||||||
|
|
||||||
|
if (CleaningPool()) return;
|
||||||
|
|
||||||
|
DeleteRenameSignWindow(this->index);
|
||||||
this->owner = INVALID_PLAYER;
|
this->owner = INVALID_PLAYER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ void PlaceProc_Sign(TileIndex tile);
|
||||||
/* signs_gui.cpp */
|
/* signs_gui.cpp */
|
||||||
void ShowRenameSignWindow(const Sign *si);
|
void ShowRenameSignWindow(const Sign *si);
|
||||||
void HandleClickOnSign(const Sign *si);
|
void HandleClickOnSign(const Sign *si);
|
||||||
|
void DeleteRenameSignWindow(SignID sign);
|
||||||
|
|
||||||
void ShowSignList();
|
void ShowSignList();
|
||||||
|
|
||||||
|
|
|
@ -286,8 +286,9 @@ struct SignWindow : QueryStringBaseWindow, SignList {
|
||||||
|
|
||||||
case QUERY_EDIT_SIGN_WIDGET_DELETE:
|
case QUERY_EDIT_SIGN_WIDGET_DELETE:
|
||||||
/* Only need to set the buffer to null, the rest is handled as the OK button */
|
/* Only need to set the buffer to null, the rest is handled as the OK button */
|
||||||
DeleteTextBufferAll(&this->text);
|
RenameSign(this->cur_sign, "");
|
||||||
/* FALL THROUGH */
|
/* don't delete this, we are deleted in Sign::~Sign() -> DeleteRenameSignWindow() */
|
||||||
|
break;
|
||||||
|
|
||||||
case QUERY_EDIT_SIGN_WIDGET_OK:
|
case QUERY_EDIT_SIGN_WIDGET_OK:
|
||||||
RenameSign(this->cur_sign, this->text.buf);
|
RenameSign(this->cur_sign, this->text.buf);
|
||||||
|
@ -358,3 +359,10 @@ void ShowRenameSignWindow(const Sign *si)
|
||||||
|
|
||||||
new SignWindow(&_query_sign_edit_desc, 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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue