Skip to content
Snippets Groups Projects
Commit 4a007f5e authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #25241: gnome: dlclose and free addressbook when exiting

parent 02db63c1
No related branches found
No related tags found
No related merge requests found
...@@ -158,6 +158,8 @@ sflphone_quit(gboolean force_quit, SFLPhoneClient *client) ...@@ -158,6 +158,8 @@ sflphone_quit(gboolean force_quit, SFLPhoneClient *client)
calllist_clean(current_calls_tab); calllist_clean(current_calls_tab);
calllist_clean(contacts_tab); calllist_clean(contacts_tab);
calllist_clean(history_tab); calllist_clean(history_tab);
free_addressbook();
#if GLIB_CHECK_VERSION(2,32,0) #if GLIB_CHECK_VERSION(2,32,0)
g_application_quit(G_APPLICATION(client)); g_application_quit(G_APPLICATION(client));
#else #else
......
...@@ -84,21 +84,26 @@ handler_async_search(GList *hits, gpointer user_data) ...@@ -84,21 +84,26 @@ handler_async_search(GList *hits, gpointer user_data)
void abook_init() void abook_init()
{ {
/* Clear any existing error */
dlerror();
const gchar *addrbook_path = PLUGINS_DIR "/libevladdrbook.so"; const gchar *addrbook_path = PLUGINS_DIR "/libevladdrbook.so";
/* FIXME: handle should be unloaded with dlclose on exit */ /* FIXME: handle should be unloaded with dlclose on exit */
void *handle = dlopen(addrbook_path, RTLD_LAZY); void *handle = dlopen(addrbook_path, RTLD_LAZY);
if (handle == NULL) { if (handle == NULL) {
g_debug("Did not load addressbook from path %s", addrbook_path); g_debug("Did not load addressbook from path %s:%s", addrbook_path, dlerror());
return; return;
} }
addrbook = g_new0(AddrBookHandle, 1); addrbook = g_new0(AddrBookHandle, 1);
/* Keep the handle around to dlclose it later */
addrbook->handle = handle;
#define LOAD(func) do { \ #define LOAD(func) do { \
addrbook-> func = dlsym(handle, "addressbook_" #func); \ addrbook-> func = dlsym(handle, "addressbook_" #func); \
if (addrbook-> func == NULL) { \ if (addrbook-> func == NULL) { \
g_warning("Couldn't load " # func); \ g_warning("Couldn't load " # func ":%s", dlerror());\
dlclose(handle); \ dlclose(handle); \
g_free(addrbook); \ g_free(addrbook); \
addrbook = NULL; \ addrbook = NULL; \
...@@ -118,3 +123,15 @@ void abook_init() ...@@ -118,3 +123,15 @@ void abook_init()
addrbook->search_cb = handler_async_search; addrbook->search_cb = handler_async_search;
} }
void
free_addressbook()
{
if (!addrbook)
return;
if (addrbook->handle)
dlclose(addrbook->handle);
g_free(addrbook);
}
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "addressbook.h" #include "addressbook.h"
void abook_init(); void abook_init();
void free_addressbook();
extern AddrBookHandle *addrbook; extern AddrBookHandle *addrbook;
......
...@@ -86,6 +86,7 @@ struct AddrBookHandle { ...@@ -86,6 +86,7 @@ struct AddrBookHandle {
void (*set_current_book)(const gchar *); void (*set_current_book)(const gchar *);
void (*set_search_type)(AddrbookSearchType); void (*set_search_type)(AddrbookSearchType);
void (*search_cb)(GList *, gpointer); void (*search_cb)(GList *, gpointer);
void *handle;
}; };
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment