Working on error handling
This commit is contained in:
parent
158ba53ca0
commit
31f95f574b
|
@ -187,12 +187,12 @@ static Properties * _properties_new(Mime * mime, char const * filename)
|
||||||
|
|
||||||
static int _new_load(Properties * properties)
|
static int _new_load(Properties * properties)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
Config * config;
|
Config * config;
|
||||||
char const * plugins = NULL;
|
char const * plugins = NULL;
|
||||||
char * p;
|
char * p;
|
||||||
char * q;
|
char * q;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
int cnt = 0;
|
||||||
|
|
||||||
p = _common_config_filename(BROWSER_CONFIG_FILE);
|
p = _common_config_filename(BROWSER_CONFIG_FILE);
|
||||||
if((config = config_new()) != NULL && config_load(config, p) == 0
|
if((config = config_new()) != NULL && config_load(config, p) == 0
|
||||||
|
@ -207,13 +207,15 @@ static int _new_load(Properties * properties)
|
||||||
{
|
{
|
||||||
if(q[i] == '\0')
|
if(q[i] == '\0')
|
||||||
{
|
{
|
||||||
ret |= _properties_load(properties, q);
|
if(_properties_load(properties, q) == 0)
|
||||||
|
cnt++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(q[i++] != ',')
|
if(q[i++] != ',')
|
||||||
continue;
|
continue;
|
||||||
q[i - 1] = '\0';
|
q[i - 1] = '\0';
|
||||||
ret |= _properties_load(properties, q);
|
if(_properties_load(properties, q) == 0)
|
||||||
|
cnt++;
|
||||||
q += i;
|
q += i;
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
@ -221,12 +223,15 @@ static int _new_load(Properties * properties)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret |= _properties_load(properties, "properties");
|
if(_properties_load(properties, "properties") == 0)
|
||||||
ret |= _properties_load(properties, "preview");
|
cnt++;
|
||||||
|
if(_properties_load(properties, "preview") == 0)
|
||||||
|
cnt++;
|
||||||
}
|
}
|
||||||
if(config != NULL)
|
if(config != NULL)
|
||||||
config_delete(config);
|
config_delete(config);
|
||||||
return ret;
|
/* consider ourselves successful if at least one plug-in was loaded */
|
||||||
|
return (cnt > 0) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -257,7 +262,7 @@ static void _properties_set_location(Properties * properties,
|
||||||
|
|
||||||
if((p = strdup(filename)) == NULL)
|
if((p = strdup(filename)) == NULL)
|
||||||
{
|
{
|
||||||
_properties_error(NULL, filename, 1);
|
_properties_error(properties, filename, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
free(properties->filename);
|
free(properties->filename);
|
||||||
|
@ -319,17 +324,17 @@ static int _properties_load(Properties * properties, char const * name)
|
||||||
GtkWidget * widget;
|
GtkWidget * widget;
|
||||||
|
|
||||||
if((p = plugin_new(LIBDIR, PACKAGE, "plugins", name)) == NULL)
|
if((p = plugin_new(LIBDIR, PACKAGE, "plugins", name)) == NULL)
|
||||||
return -_properties_error(NULL, error_get(), 1);
|
return -_properties_error(properties, error_get(), 1);
|
||||||
if((bpd = plugin_lookup(p, "plugin")) == NULL)
|
if((bpd = plugin_lookup(p, "plugin")) == NULL)
|
||||||
{
|
{
|
||||||
plugin_delete(p);
|
plugin_delete(p);
|
||||||
return -_properties_error(NULL, error_get(), 1);
|
return -_properties_error(properties, error_get(), 1);
|
||||||
}
|
}
|
||||||
if(bpd->init == NULL || bpd->destroy == NULL || bpd->get_widget == NULL
|
if(bpd->init == NULL || bpd->destroy == NULL || bpd->get_widget == NULL
|
||||||
|| (bp = bpd->init(&properties->helper)) == NULL)
|
|| (bp = bpd->init(&properties->helper)) == NULL)
|
||||||
{
|
{
|
||||||
plugin_delete(p);
|
plugin_delete(p);
|
||||||
return -_properties_error(NULL, error_get(), 1);
|
return -_properties_error(properties, error_get(), 1);
|
||||||
}
|
}
|
||||||
widget = bpd->get_widget(bp);
|
widget = bpd->get_widget(bp);
|
||||||
bpd->refresh(bp, properties->filename);
|
bpd->refresh(bp, properties->filename);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user