From 35eb251244ee360cedef6ec1143e65b59da604a8 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 17 Oct 2012 14:20:18 +0100 Subject: Fix "error setting certificate verify locations" problem when the Choices file doesn't exist. Now there's a single place for front ends to set options overrides. Fix nsoption_setnull_charp leak. --- riscos/gui.c | 81 ++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 35 deletions(-) (limited to 'riscos/gui.c') diff --git a/riscos/gui.c b/riscos/gui.c index d689094ab..93fc3db65 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -328,6 +328,47 @@ nsurl *gui_get_resource_url(const char *path) return url; } +/* Documented in desktop/options.h */ +void gui_options_init_defaults(void) +{ + /* Set defaults for absent option strings */ + nsoption_setnull_charp(theme, strdup("Aletheia")); + nsoption_setnull_charp(toolbar_browser, strdup("0123|58|9")); + nsoption_setnull_charp(toolbar_hotlist, strdup("40|12|3")); + nsoption_setnull_charp(toolbar_history, strdup("0|12|3")); + nsoption_setnull_charp(toolbar_cookies, strdup("0|12")); + nsoption_setnull_charp(ca_bundle, strdup("NetSurf:Resources.ca-bundle")); + nsoption_setnull_charp(cookie_file, strdup("NetSurf:Cookies")); + nsoption_setnull_charp(cookie_jar, strdup(CHOICES_PREFIX "Cookies")); + nsoption_setnull_charp(url_path, strdup("NetSurf:URL")); + nsoption_setnull_charp(url_save, strdup(CHOICES_PREFIX "URL")); + nsoption_setnull_charp(hotlist_path, strdup("NetSurf:Hotlist")); + nsoption_setnull_charp(hotlist_save, strdup(CHOICES_PREFIX "Hotlist")); + nsoption_setnull_charp(recent_path, strdup("NetSurf:Recent")); + nsoption_setnull_charp(recent_save, strdup(CHOICES_PREFIX "Recent")); + nsoption_setnull_charp(theme_path, strdup("NetSurf:Themes")); + nsoption_setnull_charp(theme_save, strdup(CHOICES_PREFIX "Themes")); + + if (nsoption_charp(theme) == NULL || + nsoption_charp(toolbar_browser) == NULL || + nsoption_charp(toolbar_hotlist) == NULL || + nsoption_charp(toolbar_history) == NULL || + nsoption_charp(toolbar_cookies) == NULL || + nsoption_charp(ca_bundle) == NULL || + nsoption_charp(cookie_file) == NULL || + nsoption_charp(cookie_jar) == NULL || + nsoption_charp(url_path) == NULL || + nsoption_charp(url_save) == NULL || + nsoption_charp(hotlist_path) == NULL || + nsoption_charp(hotlist_save) == NULL || + nsoption_charp(recent_path) == NULL || + nsoption_charp(recent_save) == NULL || + nsoption_charp(theme_path) == NULL || + nsoption_charp(theme_save) == NULL) { + die("Failed initialising string options"); + } +} + /** * Initialise the gui (RISC OS specific part). */ @@ -347,6 +388,7 @@ static void gui_init(int argc, char** argv) int length; char *nsdir_temp; byte *base; + char *tree_icons_dir; /* re-enable all FPU exceptions/traps except inexact operations, * which we're not interested in, and underflow which is incorrectly @@ -375,42 +417,11 @@ static void gui_init(int argc, char** argv) ro_plot_patterned_lines = false; } - /* Set defaults for absent option strings */ - nsoption_setnull_charp(theme, strdup("Aletheia")); - nsoption_setnull_charp(toolbar_browser, strdup("0123|58|9")); - nsoption_setnull_charp(toolbar_hotlist, strdup("40|12|3")); - nsoption_setnull_charp(toolbar_history, strdup("0|12|3")); - nsoption_setnull_charp(toolbar_cookies, strdup("0|12")); - nsoption_setnull_charp(ca_bundle, strdup("NetSurf:Resources.ca-bundle")); - nsoption_setnull_charp(cookie_file, strdup("NetSurf:Cookies")); - nsoption_setnull_charp(cookie_jar, strdup(CHOICES_PREFIX "Cookies")); - nsoption_setnull_charp(url_path, strdup("NetSurf:URL")); - nsoption_setnull_charp(url_save, strdup(CHOICES_PREFIX "URL")); - nsoption_setnull_charp(hotlist_path, strdup("NetSurf:Hotlist")); - nsoption_setnull_charp(hotlist_save, strdup(CHOICES_PREFIX "Hotlist")); - nsoption_setnull_charp(recent_path, strdup("NetSurf:Recent")); - nsoption_setnull_charp(recent_save, strdup(CHOICES_PREFIX "Recent")); - nsoption_setnull_charp(theme_path, strdup("NetSurf:Themes")); - nsoption_setnull_charp(theme_save, strdup(CHOICES_PREFIX "Themes")); - - tree_set_icon_dir(strdup("NetSurf:Resources.Icons")); - - if (nsoption_charp(theme) == NULL || - nsoption_charp(toolbar_browser) == NULL || - nsoption_charp(toolbar_hotlist) == NULL || - nsoption_charp(toolbar_history) == NULL || - nsoption_charp(ca_bundle) == NULL || - nsoption_charp(cookie_file) == NULL || - nsoption_charp(cookie_jar) == NULL || - nsoption_charp(url_path) == NULL || - nsoption_charp(url_save) == NULL || - nsoption_charp(hotlist_path) == NULL || - nsoption_charp(hotlist_save) == NULL || - nsoption_charp(recent_path) == NULL || - nsoption_charp(recent_save) == NULL || - nsoption_charp(theme_path) == NULL || - nsoption_charp(theme_save) == NULL) + tree_icons_dir = strdup("NetSurf:Resources.Icons"); + if (tree_icons_dir == NULL) die("Failed initialising string options"); + tree_set_icon_dir(tree_icons_dir); + /* Create our choices directories */ ro_gui_create_dirs(); -- cgit v1.2.3