aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx/c_src/wxe_callback_impl.cpp
diff options
context:
space:
mode:
authorDan Gudmundsson <dgud@ubuntu.(none)>2014-02-05 20:19:41 +0100
committerDan Gudmundsson <[email protected]>2014-02-13 16:42:36 +0100
commitce28e4940a6d313db19d996ff3cece21d7372a7b (patch)
treeaed103c158692c6f471ec597d6494693637808db /lib/wx/c_src/wxe_callback_impl.cpp
parent8d71ab498974b5f0623eac50c4f94f62fc229a94 (diff)
downloadotp-ce28e4940a6d313db19d996ff3cece21d7372a7b.tar.gz
otp-ce28e4940a6d313db19d996ff3cece21d7372a7b.tar.bz2
otp-ce28e4940a6d313db19d996ff3cece21d7372a7b.zip
wx: Rewrite eventhandling again
Remove the extra wxEvtListener that only caused confusion, now everything is automatically cleaned up by the destructors and event sent to erlang when it becomes delete for all cases.
Diffstat (limited to 'lib/wx/c_src/wxe_callback_impl.cpp')
-rw-r--r--lib/wx/c_src/wxe_callback_impl.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/wx/c_src/wxe_callback_impl.cpp b/lib/wx/c_src/wxe_callback_impl.cpp
index 8ba2557d82..e06f68dcbf 100644
--- a/lib/wx/c_src/wxe_callback_impl.cpp
+++ b/lib/wx/c_src/wxe_callback_impl.cpp
@@ -30,27 +30,27 @@
* CallbackData *
* ****************************************************************************/
-wxeCallbackData::wxeCallbackData(ErlDrvTermData caller, int req, char *req_type,
- int funcb, int skip_ev, wxeErlTerm * userData,
- wxeEvtListener *handler_cb)
- : wxObject()
+wxeEvtListener::wxeEvtListener(ErlDrvTermData caller, int req, char *req_type,
+ int funcb, int skip_ev, wxeErlTerm * userData,
+ ErlDrvTermData from_port)
+ : wxEvtHandler()
{
+ port=from_port;
listener = caller;
obj = req;
fun_id = funcb;
strcpy(class_name, req_type);
skip = skip_ev;
user_data = userData;
- handler = handler_cb;
}
-wxeCallbackData::~wxeCallbackData() {
- // fprintf(stderr, "CBD Deleteing %p %s\r\n", this, class_name); fflush(stderr);
+wxeEvtListener::~wxeEvtListener() {
+ // fprintf(stderr, "CBD Deleteing %p %s\r\n", this, class_name); fflush(stderr);
if(user_data) {
delete user_data;
}
ptrMap::iterator it;
- it = ((WxeApp *)wxTheApp)->ptr2ref.find(handler);
+ it = ((WxeApp *)wxTheApp)->ptr2ref.find(this);
if(it != ((WxeApp *)wxTheApp)->ptr2ref.end()) {
wxeRefData *refd = it->second;
wxeReturn rt = wxeReturn(WXE_DRV_PORT, refd->memenv->owner, false);
@@ -61,6 +61,17 @@ wxeCallbackData::~wxeCallbackData() {
rt.addTupleCount(4);
rt.send();
}
+ ((WxeApp *)wxTheApp)->clearPtr(this);
+}
+
+void wxeEvtListener::forward(wxEvent& event)
+{
+#ifdef DEBUG
+ if(!sendevent(&event, port))
+ fprintf(stderr, "Couldn't send event!\r\n");
+#else
+sendevent(&event, port);
+#endif
}
/* *****************************************************************/