(svn r13082) -Fix (r13042): segmentation fault due to too early deletion of OskWindow.
authorglx
Wed, 14 May 2008 01:57:12 +0000
changeset 10538 8d2fcedeb9e9
parent 10537 116b667a5956
child 10539 42f48cb0d302
(svn r13082) -Fix (r13042): segmentation fault due to too early deletion of OskWindow.
src/osk_gui.cpp
--- a/src/osk_gui.cpp	Tue May 13 22:42:10 2008 +0000
+++ b/src/osk_gui.cpp	Wed May 14 01:57:12 2008 +0000
@@ -129,6 +129,8 @@
 			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 @@
 						this->parent->OnClick(pt, this->ok_btn);
 					}
 				}
-				delete this;
+				delete_this = true;
 				break;
 
 			case OSK_WIDGET_CANCEL:
@@ -182,12 +184,13 @@
 					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()