]> git.street.me.uk Git - andy/viking.git/commitdiff
Fix relative file path loading for DEM files.
authorRob Norris <rw_norris@hotmail.com>
Sun, 7 May 2017 13:13:20 +0000 (14:13 +0100)
committerRob Norris <rw_norris@hotmail.com>
Sat, 20 May 2017 14:22:21 +0000 (15:22 +0100)
src/file.c
src/uibuilder.h
src/vikdemlayer.c
src/viklayer.c

index 4b8a4255511822e53587fa8067ff992e8045bccd..b7bff204bbdff45ee323194a3a0a15880013e560 100644 (file)
@@ -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;
index af8b60313fefcdda465828b1c85cbce35b5fc454..1e61e3f7c6d8d3853e31605b6d71a70678eeb983 100644 (file)
@@ -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 {
index 15aaaef9ddc3c3a29d9da641527f2e1953562bb8..a6579d74a67e9a0f08f18f7ca5c17bcef68c8000 100644 (file)
@@ -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),
index ad7008f5f3674dc5144169c4ae596c6e845171e3..ceb1360d3f0719a5165a0b448d6a92a330cd72d7 100644 (file)
@@ -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++ )
     {