static void webview_collect_registered_function(JSObjectRef obj) { lua_State *L = globalconf.L; gpointer ref = JSObjectGetPrivate(obj); luaH_object_unref(L, ref); }
/* Remove a global signal. * \param L The Lua VM state. * \return The number of elements pushed on stack. * \luastack * \lparam A string with the event name. * \lparam The function to call. */ static gint luaH_luakit_remove_signal(lua_State *L) { const gchar *name = luaL_checkstring(L, 1); luaH_checkfunction(L, 2); gpointer func = (gpointer) lua_topointer(L, 2); signal_remove(globalconf.signals, name, func); luaH_object_unref(L, (void *) func); return 0; }
/* Unrefs and resets the given timer and destroys its event source. * \param L The Lua VM state. * \param timer The timer structure. */ static void luaH_timer_destroy(lua_State *L, ltimer_t *timer) { GSource *source = g_main_context_find_source_by_id(NULL, timer->timer_id); if (source != NULL) { g_source_destroy(source); } luaH_object_unref(L, timer->ref); // now the timer may be garbage collected timer->ref = NULL; timer->timer_id = TIMER_STOPPED; }
static void luaH_timer_destroy(lua_State *L, ltimer_t *timer) { GSource *source = g_main_context_find_source_by_id(NULL, timer->id); if (source != NULL) g_source_destroy(source); /* allow timer to be garbage collected */ luaH_object_unref(L, timer->ref); timer->ref = NULL; timer->id = TIMER_STOPPED; }
/** * Allow garbage collection of the download. * * This function unrefs the download from the object registry. * It also deletes the backup files that may be created by WebKit while * downloading. * * \param L The Lua VM state. * \param download The \ref download_t to unref. */ static void luaH_download_unref(lua_State *L, download_t *download) { if (download->ref) { luaH_object_unref(L, download->ref); download->ref = NULL; } /* delete the annoying backup file generated while downloading */ gchar *backup = g_strdup_printf("%s~", download->destination); g_unlink(backup); g_free(backup); }