X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/db43cfa4df71667eeb27da8db6a48d3ab63e2fea..e06d3901b3cb4f2ff2c4001a174577421f6e25c2:/src/viklayer.c diff --git a/src/viklayer.c b/src/viklayer.c index dd1ce928..880c7394 100644 --- a/src/viklayer.c +++ b/src/viklayer.c @@ -3,6 +3,7 @@ * * Copyright (C) 2005, Alex Foobarian * Copyright (C) 2003-2007, Evan Battaglia + * Copyright (C) 2013, Rob Norris * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -202,7 +203,7 @@ const gchar *vik_layer_get_name ( VikLayer *l ) return l->name; } -VikLayer *vik_layer_create ( VikLayerTypeEnum type, gpointer vp, GtkWindow *w, gboolean interactive ) +VikLayer *vik_layer_create ( VikLayerTypeEnum type, VikViewport *vp, gboolean interactive ) { VikLayer *new_layer = NULL; g_assert ( type < VIK_LAYER_NUM_TYPES ); @@ -227,7 +228,7 @@ VikLayer *vik_layer_create ( VikLayerTypeEnum type, gpointer vp, GtkWindow *w, g } /* returns TRUE if OK was pressed */ -gboolean vik_layer_properties ( VikLayer *layer, gpointer vp ) +gboolean vik_layer_properties ( VikLayer *layer, VikViewport *vp ) { if ( vik_layer_interfaces[layer->type]->properties ) return vik_layer_interfaces[layer->type]->properties ( layer, vp ); @@ -296,10 +297,16 @@ void vik_layer_marshall_params ( VikLayer *vl, guint8 **data, gint *datalen ) d = get_param(vl, i, FALSE); switch ( params[i].type ) { - case VIK_LAYER_PARAM_STRING: - vlm_append(d.s, strlen(d.s)); - break; - + case VIK_LAYER_PARAM_STRING: + // Remember need braces as these are macro calls, not single statement functions! + if ( d.s ) { + vlm_append(d.s, strlen(d.s)); + } + else { + // Need to insert empty string otherwise the unmarshall will get confused + vlm_append("", 0); + } + break; /* print out the string list in the array */ case VIK_LAYER_PARAM_STRING_LIST: { GList *list = d.sl; @@ -625,6 +632,8 @@ VikLayerTypedParamData *vik_layer_data_typed_param_copy_from_string ( VikLayerPa */ void vik_layer_set_defaults ( VikLayer *vl, VikViewport *vvp ) { + // Sneaky initialize of the viewport value here + vl->vvp = vvp; VikLayerInterface *vli = vik_layer_get_interface ( vl->type ); const gchar *layer_name = vli->fixed_layer_name; VikLayerParamData data;