diff options
Diffstat (limited to '')
-rw-r--r-- | src/GuiLua/GuiLua.c | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c index 5c76e15..643a9d5 100644 --- a/src/GuiLua/GuiLua.c +++ b/src/GuiLua/GuiLua.c | |||
@@ -229,6 +229,15 @@ static int colour(lua_State *L) | |||
229 | Light user data an actual pointer. | 229 | Light user data an actual pointer. |
230 | */ | 230 | */ |
231 | 231 | ||
232 | static void _on_us_del(void *data, Evas_Object *obj, void *event_info) | ||
233 | { | ||
234 | winFang *win = data; | ||
235 | GuiLua *gl = win->data; | ||
236 | |||
237 | gl->inDel = 1; | ||
238 | GuiLuaDel(gl); | ||
239 | } | ||
240 | |||
232 | static int window(lua_State *L) | 241 | static int window(lua_State *L) |
233 | { | 242 | { |
234 | winFang *win = NULL; | 243 | winFang *win = NULL; |
@@ -247,8 +256,21 @@ static int window(lua_State *L) | |||
247 | 256 | ||
248 | win = winFangAdd(parent, 25, 25, w, h, title, name); | 257 | win = winFangAdd(parent, 25, 25, w, h, title, name); |
249 | // If there's no parent, we become the parent. | 258 | // If there's no parent, we become the parent. |
250 | if (gl && !parent) | 259 | if (gl) |
251 | gl->parent = win; | 260 | { |
261 | // If there's no parent, we become the parent. | ||
262 | if (!parent) | ||
263 | gl->parent = win; | ||
264 | // If there's no us, we must be the first, so we are us. | ||
265 | if (!gl->us) | ||
266 | { | ||
267 | gl->us = win; | ||
268 | // TODO - If this invocation of GuiLuaDo never opens a window, then this GuiLua will never get deleted. | ||
269 | // Also, who ever opened this window might have other plans for on_del or data. | ||
270 | win->data = gl; | ||
271 | win->on_del = _on_us_del; | ||
272 | } | ||
273 | } | ||
252 | lua_pushlightuserdata(L, win); | 274 | lua_pushlightuserdata(L, win); |
253 | 275 | ||
254 | return 1; | 276 | return 1; |
@@ -399,8 +421,8 @@ GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent) | |||
399 | // This does nothing if no module opened a window. | 421 | // This does nothing if no module opened a window. |
400 | if (0 != luaL_dostring(L, "skang.loopWindow()")) | 422 | if (0 != luaL_dostring(L, "skang.loopWindow()")) |
401 | PE("Error running - skang.loopWindow()"); | 423 | PE("Error running - skang.loopWindow()"); |
402 | lua_pop(L, closeWindow(L)); | 424 | GuiLuaDel(result); |
403 | lua_close(L); | 425 | result = NULL; |
404 | if (logDom >= 0) | 426 | if (logDom >= 0) |
405 | { | 427 | { |
406 | eina_log_domain_unregister(logDom); | 428 | eina_log_domain_unregister(logDom); |
@@ -416,3 +438,14 @@ GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent) | |||
416 | 438 | ||
417 | return result; | 439 | return result; |
418 | } | 440 | } |
441 | |||
442 | void GuiLuaDel(GuiLua *gl) | ||
443 | { | ||
444 | if (gl) | ||
445 | { | ||
446 | gl->us->on_del = NULL; | ||
447 | if (!gl->inDel) winFangDel(gl->us); | ||
448 | if (gl->L) lua_close(gl->L); | ||
449 | free(gl); | ||
450 | } | ||
451 | } | ||