From: Rob Norris Date: Sat, 2 May 2015 10:51:45 +0000 (+0100) Subject: Red Hat Bugzilla – Bug 1210403: Only download and process one Bing attribution list. X-Git-Url: https://git.street.me.uk/andy/viking.git/commitdiff_plain/a1ed03fb6a7031b5a9e79aea3b084afe8d2e6396 Red Hat Bugzilla – Bug 1210403: Only download and process one Bing attribution list. If making more than one download request to get the Bing attributions, but then updating (and using) a single instance variable from multiple threads, results in undefined behaviour (i.e. could lead to crashes). Thus ensure only one request at a time is made. --- diff --git a/src/bingmapsource.c b/src/bingmapsource.c index 7a3887ad..917d5302 100644 --- a/src/bingmapsource.c +++ b/src/bingmapsource.c @@ -79,6 +79,7 @@ struct _BingMapSourcePrivate GList *attributions; /* Current attribution, when parsing */ gchar *attribution; + gboolean loading_attributions; }; /* The pixbuf to store the logo */ @@ -109,6 +110,7 @@ bing_map_source_init (BingMapSource *self) priv->api_key = NULL; priv->attributions = NULL; priv->attribution = NULL; + priv->loading_attributions = FALSE; } static void @@ -297,7 +299,11 @@ _get_copyright(VikMapSource * self, LatLonBBox bbox, gdouble zoom, void (*fct)(V /* Loop over all known attributions */ GList *attribution = priv->attributions; if (attribution == NULL && g_strcmp0 ("", priv->api_key)) { - _async_load_attributions (BING_MAP_SOURCE (self)); + if ( ! priv->loading_attributions ) + _async_load_attributions (BING_MAP_SOURCE (self)); + else + // Wait until attributions loaded before processing them + return; } while (attribution != NULL) { struct _Attribution *current = (struct _Attribution*)attribution->data; @@ -462,6 +468,7 @@ _load_attributions ( BingMapSource *self ) } done: + priv->loading_attributions = FALSE; g_free(uri); g_remove(tmpname); g_free(tmpname);