From 00e2f5d882349300aa95a54dd50132aa4fac881a Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Wed, 4 Mar 2015 10:31:48 +0000 Subject: [PATCH] elua: connect the del event on first callback connect --- src/bindings/luajit/eo.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bindings/luajit/eo.lua b/src/bindings/luajit/eo.lua index 4e047bc..22f9094 100644 --- a/src/bindings/luajit/eo.lua +++ b/src/bindings/luajit/eo.lua @@ -159,17 +159,21 @@ local connect = function(self, ename, func, priority) end local cl = eo_classes["Eo_Base"] -- add the callback to the respective array + local cdel = false local addr = eo_obj_addr_get(self) local cbs = eo_callbacks[addr] if not cbs then cbs = {} eo_callbacks[addr] = cbs + cdel = true end local cidx = #cbs + 1 cbs[cidx] = func M.__do_start(self, cl) eo.eo_event_callback_priority_add(ev, priority or 0, eo_event_cb, ffi.cast("void *", cidx)) + eo.eo_event_callback_priority_add(eo._EO_BASE_EVENT_DEL, 0, eo_event_del, + nil) M.__do_end() return true end @@ -318,8 +322,6 @@ M.__ctor_common = function(klass, parent, ctor, loff, ...) ret = eo.eo_finalize() eo._eo_do_end(nil) end - eo.eo_event_callback_priority_add(eo._EO_BASE_EVENT_DEL, 0, eo_event_del, - nil) ffi.gc(ret, obj_gccb) return ret end -- 2.7.4