From: Freddy Date: Sun, 5 Jan 2020 21:14:10 +0000 (+0100) Subject: TextBox: properly delete buffer X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=18aa9d447d72b7b0c6be75d2d8e744431c2c80db;p=xonotic%2Fxonotic-data.pk3dir.git TextBox: properly delete buffer --- diff --git a/qcsrc/menu/xonotic/textbox.qc b/qcsrc/menu/xonotic/textbox.qc index 4e6817d37..efad0e8ea 100644 --- a/qcsrc/menu/xonotic/textbox.qc +++ b/qcsrc/menu/xonotic/textbox.qc @@ -8,8 +8,23 @@ entity makeXonoticTextBox() return me; } +void XonoticTextBox_destroy(entity me) +{ + if (me.stringList >= 0) + { + buf_del(me.stringList); + me.stringList = -1; + } +} + void XonoticTextBox_setText(entity me, string text) { + if (me.stringList >= 0) + { + buf_del(me.stringList); + me.stringList = -1; + } + int buf; int line = 0; @@ -34,7 +49,11 @@ void XonoticTextBox_setText(entity me, string text) string XonoticTextBox_getTextBoxContent(entity me, int i) { - return bufstr_get(me.stringList, i); + if (me.stringList >= 0) + { + return bufstr_get(me.stringList, i); + } + return string_null; } // mostly copied from playerlist diff --git a/qcsrc/menu/xonotic/textbox.qh b/qcsrc/menu/xonotic/textbox.qh index 323a9bb2b..4f8c6633c 100644 --- a/qcsrc/menu/xonotic/textbox.qh +++ b/qcsrc/menu/xonotic/textbox.qh @@ -4,6 +4,7 @@ // slightly hacky multiline textbox with scrollbar CLASS(XonoticTextBox, XonoticListBox) + METHOD(XonoticTextBox, destroy, void(entity)); ATTRIB(XonoticTextBox, rowsPerItem, float, 1); METHOD(XonoticTextBox, resizeNotify, void(entity, vector, vector, vector, vector)); METHOD(XonoticTextBox, drawListBoxItem, void(entity, int, vector, bool, bool));