mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 03:45:59 +01:00
always close the plugin handle
This commit is contained in:
parent
cd842a8f48
commit
719557ff9e
3 changed files with 18 additions and 33 deletions
|
@ -22,6 +22,7 @@ GIRARA_LIB ?= $(shell pkg-config --libs girara-gtk2)
|
||||||
SQLITE_INC ?= $(shell pkg-config --cflags sqlite3)
|
SQLITE_INC ?= $(shell pkg-config --cflags sqlite3)
|
||||||
SQLITE_LIB ?= $(shell pkg-config --libs sqlite3)
|
SQLITE_LIB ?= $(shell pkg-config --libs sqlite3)
|
||||||
|
|
||||||
|
#set it to an empty value if you don't need to link against ld for dlopen and friends
|
||||||
DL_LIB ?= -ldl
|
DL_LIB ?= -ldl
|
||||||
|
|
||||||
INCS = ${GIRARA_INC} ${GTK_INC}
|
INCS = ${GIRARA_INC} ${GTK_INC}
|
||||||
|
|
45
document.c
45
document.c
|
@ -22,17 +22,15 @@
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register document plugin
|
||||||
|
*/
|
||||||
|
static bool zathura_document_plugin_register(zathura_t* zathura, zathura_document_plugin_t* new_plugin);
|
||||||
|
|
||||||
void
|
void
|
||||||
zathura_document_plugins_load(zathura_t* zathura)
|
zathura_document_plugins_load(zathura_t* zathura)
|
||||||
{
|
{
|
||||||
girara_list_iterator_t* iter = girara_list_iterator(zathura->plugins.path);
|
GIRARA_LIST_FOREACH(zathura->plugins.path, char*, iter, plugindir)
|
||||||
if (iter == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
char* plugindir = girara_list_iterator_data(iter);
|
|
||||||
|
|
||||||
/* read all files in the plugin directory */
|
/* read all files in the plugin directory */
|
||||||
DIR* dir = opendir(plugindir);
|
DIR* dir = opendir(plugindir);
|
||||||
|
@ -86,25 +84,17 @@ zathura_document_plugins_load(zathura_t* zathura)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin = malloc(sizeof(zathura_document_plugin_t));
|
plugin = g_malloc0(sizeof(zathura_document_plugin_t));
|
||||||
|
plugin->content_types = girara_list_new2(g_free);
|
||||||
if (plugin == NULL) {
|
plugin->handle = handle;
|
||||||
g_error("failed to allocate memory!");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin->open_function = NULL;
|
|
||||||
plugin->content_types = girara_list_new();
|
|
||||||
girara_list_set_free_function(plugin->content_types, g_free);
|
|
||||||
|
|
||||||
register_plugin(plugin);
|
register_plugin(plugin);
|
||||||
|
|
||||||
bool r = zathura_document_plugin_register(zathura, plugin, handle);
|
bool r = zathura_document_plugin_register(zathura, plugin);
|
||||||
|
|
||||||
if (r == false) {
|
if (r == false) {
|
||||||
girara_error("could not register plugin %s", path);
|
girara_error("could not register plugin %s", path);
|
||||||
free(plugin);
|
zathura_document_plugin_free(plugin);
|
||||||
dlclose(handle);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
girara_info("successfully loaded plugin %s", path);
|
girara_info("successfully loaded plugin %s", path);
|
||||||
|
@ -116,8 +106,7 @@ zathura_document_plugins_load(zathura_t* zathura)
|
||||||
if (closedir(dir) == -1) {
|
if (closedir(dir) == -1) {
|
||||||
girara_error("could not close plugin directory %s", plugindir);
|
girara_error("could not close plugin directory %s", plugindir);
|
||||||
}
|
}
|
||||||
} while (girara_list_iterator_next(iter));
|
GIRARA_LIST_FOREACH_END(zathura->plugins.path, char*, iter, plugindir);
|
||||||
girara_list_iterator_free(iter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -127,15 +116,15 @@ zathura_document_plugin_free(zathura_document_plugin_t* plugin)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dlclose(plugin->handle);
|
||||||
girara_list_free(plugin->content_types);
|
girara_list_free(plugin->content_types);
|
||||||
free(plugin);
|
g_free(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
static bool
|
||||||
zathura_document_plugin_register(zathura_t* zathura, zathura_document_plugin_t* new_plugin, void* handle)
|
zathura_document_plugin_register(zathura_t* zathura, zathura_document_plugin_t* new_plugin)
|
||||||
{
|
{
|
||||||
if( (new_plugin == NULL) || (new_plugin->content_types == NULL) || (new_plugin->open_function == NULL)
|
if( (new_plugin == NULL) || (new_plugin->content_types == NULL) || (new_plugin->open_function == NULL) ) {
|
||||||
|| (handle == NULL) ) {
|
|
||||||
girara_error("plugin: could not register\n");
|
girara_error("plugin: could not register\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,11 +268,6 @@ void zathura_document_plugins_load(zathura_t* zathura);
|
||||||
*/
|
*/
|
||||||
void zathura_document_plugin_free(zathura_document_plugin_t* plugin);
|
void zathura_document_plugin_free(zathura_document_plugin_t* plugin);
|
||||||
|
|
||||||
/**
|
|
||||||
* Register document plugin
|
|
||||||
*/
|
|
||||||
bool zathura_document_plugin_register(zathura_t* zathura, zathura_document_plugin_t* new_plugin, void* handle);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the document
|
* Open the document
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue