From: Rob Norris Date: Sun, 7 May 2017 13:13:20 +0000 (+0100) Subject: Fix relative file path loading for DEM files. X-Git-Url: https://git.street.me.uk/andy/viking.git/commitdiff_plain/b6db1dc4ad42f87f92dfe5511b1203dff8f8549d Fix relative file path loading for DEM files. --- diff --git a/src/file.c b/src/file.c index 4b8a4255..b7bff204 100644 --- a/src/file.c +++ b/src/file.c @@ -259,6 +259,7 @@ static void string_list_set_param (gint i, GList *list, gpointer *layer_and_vp) vlsp.data.sl = list; vlsp.vp = layer_and_vp[1]; vlsp.is_file_operation = TRUE; + vlsp.dirpath = (const gchar*)layer_and_vp[2]; vik_layer_set_param ( VIK_LAYER(layer_and_vp[0]), &vlsp ); } @@ -520,6 +521,7 @@ static gboolean file_read ( VikAggregateLayer *top, FILE *f, const gchar *dirpat vlsp.data = x; vlsp.vp = vp; vlsp.is_file_operation = TRUE; + vlsp.dirpath = dirpath; vik_layer_set_param ( VIK_LAYER(stack->data), &vlsp ); } found_match = TRUE; diff --git a/src/uibuilder.h b/src/uibuilder.h index af8b6031..1e61e3f7 100644 --- a/src/uibuilder.h +++ b/src/uibuilder.h @@ -45,6 +45,7 @@ typedef struct { VikLayerParamData data; gpointer vp; // AKA VikViewport* gboolean is_file_operation; // denotes if for file I/O, as opposed to display/cut/copy etc... operations + const gchar* dirpath; // The directory - so if the data is a relative file path, we know what it is relative to } VikLayerSetParam; typedef enum { diff --git a/src/vikdemlayer.c b/src/vikdemlayer.c index 15aaaef9..a6579d74 100644 --- a/src/vikdemlayer.c +++ b/src/vikdemlayer.c @@ -427,14 +427,16 @@ gboolean dem_layer_set_param ( VikDEMLayer *vdl, VikLayerSetParam *vlsp ) { // Clear out old settings - if any commonalities with new settings they will have to be read again a_dems_list_free ( vdl->files ); + // Set file list so any other intermediate screen drawing updates will show currently loaded DEMs by the working thread - vdl->files = vlsp->data.sl; + // Ensure resolving of any relative path names + util_make_absolute_filenames ( vdl->files, vlsp->dirpath ); + // No need for thread if no files if ( vdl->files ) { // Thread Load dem_load_thread_data *dltd = g_malloc ( sizeof(dem_load_thread_data) ); dltd->vdl = vdl; - dltd->vdl->files = vlsp->data.sl; a_background_thread ( BACKGROUND_POOL_LOCAL, VIK_GTK_WINDOW_FROM_WIDGET(vlsp->vp), diff --git a/src/viklayer.c b/src/viklayer.c index ad7008f5..ceb1360d 100644 --- a/src/viklayer.c +++ b/src/viklayer.c @@ -384,6 +384,7 @@ void vik_layer_unmarshall_params ( VikLayer *vl, guint8 *data, gint datalen, Vik VikLayerSetParam vlsp; vlsp.vp = vvp; vlsp.is_file_operation = FALSE; + vlsp.dirpath = NULL; guint16 i, params_count = vik_layer_get_interface(vl->type)->params_count; for ( i = 0; i < params_count; i++ ) {