From 7e1b690b7463bd4bf5d6440d372c6766b0717934 Mon Sep 17 00:00:00 2001 From: Mason Larobina Date: Mon, 16 Aug 2010 16:28:28 +0800 Subject: [PATCH] Set destructor = NULL in destroy func to prevent it being called twice --- widget.c | 2 +- widgets/common.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/widget.c b/widget.c index 6461c77..2b6ac64 100644 --- a/widget.c +++ b/widget.c @@ -44,7 +44,7 @@ static gint luaH_widget_gc(lua_State *L) { widget_t *w = luaH_checkudata(L, 1, &widget_class); - debug("collecting widget at %p", w); + debug("collecting widget at %p of type '%s'", w, w->info->name); if(w->destructor) w->destructor(w); return luaH_object_gc(L); diff --git a/widgets/common.c b/widgets/common.c index c0985bd..0c60ddc 100644 --- a/widgets/common.c +++ b/widgets/common.c @@ -189,6 +189,7 @@ luaH_widget_destroy(lua_State *L) widget_t *w = luaH_checkudata(L, 1, &widget_class); if (w->destructor) w->destructor(w); + w->destructor = NULL; debug("unreffing widget %p of type '%s'", w, w->info->name); luaH_object_unref(L, w->ref); return 0; -- 2.11.4.GIT