aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/GuiLua/GuiLua.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-06 18:57:34 +1000
committerDavid Walter Seikel2014-05-06 18:57:34 +1000
commit531eb79446860230aec4cdbcad550c14a38ea4df (patch)
tree97182c8c1418b6290422551dcf05f4e4a3a938d0 /src/GuiLua/GuiLua.c
parentNow that everything is a winFang, GuiLua doesn't have to track it's own child... (diff)
downloadSledjHamr-531eb79446860230aec4cdbcad550c14a38ea4df.zip
SledjHamr-531eb79446860230aec4cdbcad550c14a38ea4df.tar.gz
SledjHamr-531eb79446860230aec4cdbcad550c14a38ea4df.tar.bz2
SledjHamr-531eb79446860230aec4cdbcad550c14a38ea4df.tar.xz
GuiLua's self delete when their first window gets deleted.
Diffstat (limited to 'src/GuiLua/GuiLua.c')
-rw-r--r--src/GuiLua/GuiLua.c41
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
232static 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
232static int window(lua_State *L) 241static 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
442void 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}