From 14db3f7c70de616d264b8dbe854e134bd1071bb4 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 22 Sep 2011 15:10:22 +0000 Subject: make resource path discovery robust when no resources can be found svn path=/trunk/netsurf/; revision=12860 --- gtk/gui.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/gtk/gui.c b/gtk/gui.c index abd02f1c2..94e68b84a 100644 --- a/gtk/gui.c +++ b/gtk/gui.c @@ -346,19 +346,23 @@ static void gui_init(int argc, char** argv, char **respath) /* check user options */ check_options(respath); + /* find the languages file */ + languages_file_location = filepath_find(respath, "languages"); + if ((languages_file_location == NULL) || + (strlen(languages_file_location) < 10)) { + die("Unable to find resources.\n"); + } + /* Obtain resources path location. * * Uses the directory the languages file was found in, - * previously the location of the glade files was used, - * however these may be translated which breaks things - * relying on res_dir_location. - */ - resource_filename = filepath_find(respath, "languages"); - resource_filename[strlen(resource_filename) - 9] = 0; - res_dir_location = resource_filename; - - /* languages file */ - languages_file_location = filepath_find(respath, "languages"); + * @todo find and slaughter all references to this! + */ + res_dir_location = calloc(1, strlen(languages_file_location) - 8); + memcpy(res_dir_location, + languages_file_location, + strlen(languages_file_location) - 9); + LOG(("Using '%s' for resource path", res_dir_location)); /* initialise the glade templates */ nsgtk_init_glade(respath); -- cgit v1.2.3