onefang pushed a commit to branch edje-1.7.

commit af64e0585f858b1e04aab8cf124959bc8072e07a
Author: David Walter Seikel <[email protected]>
Date:   Wed May 29 09:29:33 2013 +1000

    Backport "Stop leaking evas objects in Lua."
---
 ChangeLog           |  3 +++
 NEWS                |  1 +
 src/lib/edje_lua2.c | 10 +++++++---
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c1aa86c..082a90d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -706,3 +706,6 @@
 2013-05-16  Tom Hacohen (TAsn)
 
         * Edje textblock: Fixed issue with quoted formats.
+
+2013-05-29  David Seikel (onefang)
+       * Lua: Stop leaking evas objects in Lua.
diff --git a/NEWS b/NEWS
index 86e6268..692f3d7 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Changes since Edje 1.7.7:
 
 Fixes:
     * Edje textblock: Fixed issue with quoted formats.
+    * Edje Lua: Stop leaking evas objects in Lua.
 
 Edje 1.7.7
 
diff --git a/src/lib/edje_lua2.c b/src/lib/edje_lua2.c
index d48b450..d1d9dd2 100644
--- a/src/lib/edje_lua2.c
+++ b/src/lib/edje_lua2.c
@@ -327,9 +327,13 @@ _elua_obj_new(lua_State *L, Edje *ed, int size, const char 
*metatable)  // Stack
 }
 
 static void
-_elua_obj_free(lua_State *L __UNUSED__, Edje_Lua_Obj *obj)
+_elua_obj_free(lua_State *L, Edje_Lua_Obj *obj)
 {
    if (!obj->free_func) return;
+   // Free the reference, so it will actually get gc'd.
+   // It seems that being a completely weak table isn't enough.
+   lua_pushnil(L);                                  // Stack usage [-0, +1, -]
+   _elua_ref_set(L, obj);                           // Stack usage [-4, +4, m]
    obj->free_func(obj);
    obj->ed->lua_objs = eina_inlist_remove(obj->ed->lua_objs, 
EINA_INLIST_GET(obj));
    obj->free_func = NULL;
@@ -3888,7 +3892,7 @@ _elua_init(void)
    lua_pushlightuserdata(L, &_elua_objs);                                      
            // Stack usage [-0, +1, -]
    lua_newtable(L);                                                            
            // Stack usage [-0, +1, m]
    lua_pushstring(L, "__mode");                                                
            // Stack usage [-0, +1, m]
-   lua_pushstring(L, "v");                                                     
            // Stack usage [-0, +1, m]
+   lua_pushstring(L, "kv");                                                    
            // Stack usage [-0, +1, m]
    lua_rawset(L, -3);                                                          
            // Stack usage [-2, +0, m]
    lua_rawset(L, LUA_REGISTRYINDEX);                                           
            // Stack usage [-2, +0, m]
 }
@@ -3978,7 +3982,7 @@ _edje_lua2_script_init(Edje *ed)                          
        // Stack usage
    lua_pushlightuserdata(L, &_elua_objs);                         // Stack 
usage [-0, +1, -]
    lua_newtable(L);                                               // Stack 
usage [-0, +1, m]
    lua_pushstring(L, "__mode");                                   // Stack 
usage [-0, +1, m]
-   lua_pushstring(L, "v");                                        // Stack 
usage [-0, +1, m]
+   lua_pushstring(L, "kv");                                       // Stack 
usage [-0, +1, m]
    lua_rawset(L, -3);                                             // Stack 
usage [-2, +0, m]
    lua_rawset(L, LUA_REGISTRYINDEX);                              // Stack 
usage [-2, +0, m]
 

-- 

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1

Reply via email to