1757 }; |
1757 }; |
1758 hk_run_handlers("hook-lua-start", args); |
1758 hk_run_handlers("hook-lua-start", args); |
1759 } |
1759 } |
1760 } |
1760 } |
1761 |
1761 |
1762 static void lua_events_destroy ( gpointer data ) |
1762 static void lua_events_destroy ( gpointer data, gpointer udata ) |
1763 { |
1763 { |
1764 lua_event_callback_t *cb = data; |
1764 lua_event_callback_t *cb = data; |
1765 const char *evid; |
1765 const char *evid; |
1766 if (cb->evid == LUA_NOREF) |
1766 if (cb->evid == LUA_NOREF) |
1767 return; |
1767 return; |
1768 lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->evid); |
1768 lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->evid); |
1769 evid = lua_tostring (cb ->L, -1); |
1769 evid = lua_tostring (cb ->L, -1); |
1770 evs_callback (evid, EVS_CONTEXT_CANCEL, "Module unloading"); |
1770 evs_callback (evid, EVS_CONTEXT_CANCEL, "Module unloading"); |
1771 evs_del (evid); // XXX before these were two different runs. is there some reason for that? |
1771 evs_del (evid); |
1772 } |
1772 } |
1773 |
1773 |
1774 static void lua_bgreads_destroy ( gpointer data ) |
1774 static void lua_bgreads_destroy ( gpointer data, gpointer udata ) |
1775 { |
1775 { |
1776 g_source_remove ( ( gulong ) data ); |
1776 g_source_remove ( ( gulong ) data ); |
1777 } |
1777 } |
1778 |
1778 |
1779 static void lua_timers_destroy ( gpointer data ) |
1779 static void lua_timers_destroy ( gpointer data, gpointer udata ) |
1780 { |
1780 { |
1781 g_source_remove ( ( gulong ) data ); |
1781 g_source_remove ( ( gulong ) data ); |
1782 } |
1782 } |
1783 |
1783 |
1784 static void lua_features_destroy ( gpointer data ) |
1784 static void lua_features_destroy ( gpointer data, gpointer udata ) |
1785 { |
1785 { |
1786 gchar *xmlns = data; |
1786 gchar *xmlns = data; |
1787 xmpp_del_feature (xmlns); |
1787 xmpp_del_feature (xmlns); |
1788 g_free (xmlns); |
1788 g_free (xmlns); |
1789 } |
1789 } |
1790 |
1790 |
1791 static void lua_categories_destroy ( gpointer data ) |
1791 static void lua_categories_destroy ( gpointer data, gpointer udata ) |
1792 { |
1792 { |
1793 compl_del_category ( ( gulong ) data ); |
1793 compl_del_category ( ( gulong ) data ); |
1794 } |
1794 } |
1795 |
1795 |
1796 void mlua_uninit (void) |
1796 void mlua_uninit (void) |
1803 |
1803 |
1804 // hook handlers and commands will be unregistered upon objects destruction |
1804 // hook handlers and commands will be unregistered upon objects destruction |
1805 |
1805 |
1806 lua_guard_uninit ( lua ); |
1806 lua_guard_uninit ( lua ); |
1807 |
1807 |
1808 g_slist_free_full ( lua_bgreads, lua_bgreads_destroy ); |
1808 g_slist_foreach ( lua_bgreads, lua_bgreads_destroy, NULL ); |
|
1809 g_slist_free ( lua_bgreads ); |
1809 lua_bgreads = NULL; |
1810 lua_bgreads = NULL; |
1810 |
1811 |
1811 g_slist_free_full ( lua_timers, lua_timers_destroy ); |
1812 g_slist_foreach ( lua_timers, lua_timers_destroy, NULL ); |
|
1813 g_slist_free ( lua_timers ); |
1812 lua_timers = NULL; |
1814 lua_timers = NULL; |
1813 |
1815 |
1814 g_slist_free_full ( lua_events, lua_events_destroy ); |
1816 g_slist_foreach ( lua_events, lua_events_destroy, NULL ); |
|
1817 g_slist_free ( lua_events ); |
1815 lua_events = NULL; |
1818 lua_events = NULL; |
1816 |
1819 |
1817 #ifdef MCABBER_API_HAVE_CMD_ID |
1820 #ifdef MCABBER_API_HAVE_CMD_ID |
1818 cmd_del (lua_cmdid); |
1821 cmd_del (lua_cmdid); |
1819 lua_cmdid = NULL; |
1822 lua_cmdid = NULL; |
1822 #endif |
1825 #endif |
1823 |
1826 |
1824 lua_close (lua); |
1827 lua_close (lua); |
1825 lua = NULL; |
1828 lua = NULL; |
1826 |
1829 |
1827 g_slist_free_full ( lua_added_features, lua_features_destroy ); |
1830 g_slist_foreach ( lua_added_features, lua_features_destroy, NULL ); |
|
1831 g_slist_free ( lua_added_features ); |
1828 lua_added_features = NULL; |
1832 lua_added_features = NULL; |
1829 |
1833 |
1830 g_slist_free_full ( lua_added_categories, lua_categories_destroy ); |
1834 g_slist_foreach ( lua_added_categories, lua_categories_destroy, NULL ); |
|
1835 g_slist_free ( lua_added_categories ); |
1831 lua_added_categories = NULL; |
1836 lua_added_categories = NULL; |
1832 |
1837 |
1833 #ifdef LLM_LOG_HANDLER |
1838 #ifdef LLM_LOG_HANDLER |
1834 // FIXME: shouldn't be here |
1839 // FIXME: shouldn't be here |
1835 g_log_remove_handler ("lua-lm", lua_lm_log_handler_id); |
1840 g_log_remove_handler ("lua-lm", lua_lm_log_handler_id); |