aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx/c_src/wxe_helpers.h
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2014-01-23 15:33:09 +0100
committerDan Gudmundsson <[email protected]>2014-01-23 15:33:09 +0100
commitfd055cf43486358a413a1fa22f30f0aa711d25e1 (patch)
tree2439dfc1481c3f3fb9225564e192bf234ccf829a /lib/wx/c_src/wxe_helpers.h
parent84a83493c2bd9b01b3d90a2ebef49b0c698c0797 (diff)
downloadotp-fd055cf43486358a413a1fa22f30f0aa711d25e1.tar.gz
otp-fd055cf43486358a413a1fa22f30f0aa711d25e1.tar.bz2
otp-fd055cf43486358a413a1fa22f30f0aa711d25e1.zip
wx: Delay all deletes if recursed in event loop
Avoids crashes.
Diffstat (limited to 'lib/wx/c_src/wxe_helpers.h')
-rw-r--r--lib/wx/c_src/wxe_helpers.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/wx/c_src/wxe_helpers.h b/lib/wx/c_src/wxe_helpers.h
index c8a7e35bdb..659bc666c6 100644
--- a/lib/wx/c_src/wxe_helpers.h
+++ b/lib/wx/c_src/wxe_helpers.h
@@ -43,7 +43,10 @@ class wxeCommand : public wxObject
{
public:
wxeCommand(int fc,char * cbuf,int buflen, wxe_data *);
- virtual ~wxeCommand();
+ virtual ~wxeCommand(); // Use Delete()
+
+ wxeCommand * Save() {ref_count++; return this; };
+ void Delete() {if(--ref_count < 1) delete this;};
ErlDrvTermData caller;
ErlDrvTermData port;
@@ -51,6 +54,7 @@ class wxeCommand : public wxObject
char * buffer;
int len;
int op;
+ int ref_count;
};
class intListElement {
@@ -65,6 +69,13 @@ class intListElement {
class intList {
public:
intList() {list = NULL;};
+ ~intList() {
+ intListElement *head = list;
+ while(head) {
+ intListElement *tail=head->cdr;
+ delete head;
+ head = tail;
+ } };
bool IsEmpty() {return list == NULL;};
void Append(int Element) { list = new intListElement(Element, list); };
int Pop() {