summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2008-05-14 01:57:12 +0000
committerglx <glx@openttd.org>2008-05-14 01:57:12 +0000
commit015dbc6e7bdc72df94d53ad86d5f42037d97f47e (patch)
treeb88dd7dc8825c9f2431823ca589cfa2776f9625a
parent1ce52ef5cb52e1c4d60679c98f7282f137eb6f57 (diff)
downloadopenttd-015dbc6e7bdc72df94d53ad86d5f42037d97f47e.tar.xz
(svn r13082) -Fix (r13042): segmentation fault due to too early deletion of OskWindow.
-rw-r--r--src/osk_gui.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp
index b3955a822..49d869765 100644
--- a/src/osk_gui.cpp
+++ b/src/osk_gui.cpp
@@ -129,6 +129,8 @@ struct OskWindow : public Window {
return;
}
+ bool delete_this = false;
+
switch (widget) {
case OSK_WIDGET_BACKSPACE:
if (DeleteTextBufferChar(&this->qs->text, WKC_BACKSPACE)) this->InvalidateWidget(OSK_WIDGET_TEXT);
@@ -171,7 +173,7 @@ struct OskWindow : public Window {
this->parent->OnClick(pt, this->ok_btn);
}
}
- delete this;
+ delete_this = true;
break;
case OSK_WIDGET_CANCEL:
@@ -182,12 +184,13 @@ struct OskWindow : public Window {
strcpy(qs->text.buf, this->orig_str_buf);
UpdateTextBufferSize(&qs->text);
MoveTextBufferPos(&qs->text, WKC_END);
- delete this;
+ delete_this = true;
}
break;
}
/* make sure that the parent window's textbox also gets updated */
if (this->parent != NULL) this->parent->InvalidateWidget(this->text_btn);
+ if (delete_this) delete this;
}
virtual void OnMouseLoop()