From: Jerome St-Louis Date: Sat, 28 Mar 2015 09:15:45 +0000 (-0400) Subject: ecere/gui/controls/DropBox: Extra safety to avoid crashes X-Git-Tag: 0.44.12~18 X-Git-Url: https://ecere.com/cgi-bin/gitweb.cgi?p=sdk;a=commitdiff_plain;h=ac6076656e557d70a57da428102db90632f91499 ecere/gui/controls/DropBox: Extra safety to avoid crashes --- diff --git a/ecere/src/gui/controls/DropBox.ec b/ecere/src/gui/controls/DropBox.ec index 9f56dbf..616e2cd 100644 --- a/ecere/src/gui/controls/DropBox.ec +++ b/ecere/src/gui/controls/DropBox.ec @@ -235,12 +235,14 @@ public: virtual void OnCloseDropDown(Window pullDown) { + incref this; listBox.visible = false; if(style.editText) { editBox.ActivateEx(true, false, false, false, null, null); editBox.SelectAll(); } + delete this; } // Methods @@ -857,6 +859,8 @@ private: bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods) { + bool result = true; + incref this; Update(null); // Add code to set text to list box contents if it has an editbox @@ -868,7 +872,10 @@ private: button.checked = false; mods.closingDropDown = true; if(!NotifyClose(master, this)) + { + delete this; return false; + } } currentRow = (row && !row.noneRow) ? row : null; if(style.editText && style.changeContents) @@ -882,7 +889,9 @@ private: editBox.SelectAll(); } button.Deactivate(); - return NotifySelect(master, this, currentRow, mods); + result = NotifySelect(master, this, currentRow, mods); + delete this; + return result; } bool NotifyHighlight(ListBox control, DataRow row, Modifiers mods)