From 5698bbe5f387393ba8161eb0cda0e6f91dee8200 Mon Sep 17 00:00:00 2001 From: Pierre-Luc Beaudoin Date: Sat, 17 Oct 2009 14:09:27 -0400 Subject: [PATCH] Fix 598106: champlain plugin: map isn't displayed by not passing NULL to soup_uri_new and don't leak it --- champlain/champlain-network-map-source.c | 36 ++++++++++++++++++------ 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/champlain/champlain-network-map-source.c b/champlain/champlain-network-map-source.c index 8abbfbf..883d296 100644 --- a/champlain/champlain-network-map-source.c +++ b/champlain/champlain-network-map-source.c @@ -138,13 +138,25 @@ champlain_network_map_source_set_property (GObject *object, priv->offline = g_value_get_boolean (value); break; case PROP_PROXY_URI: - g_free (priv->proxy_uri); + { + SoupURI *uri = NULL; - priv->proxy_uri = g_value_dup_string (value); - if (soup_session) - g_object_set (G_OBJECT (soup_session), "proxy-uri", - soup_uri_new (priv->proxy_uri), NULL); - break; + g_free (priv->proxy_uri); + + priv->proxy_uri = g_value_dup_string (value); + if (priv->proxy_uri) + uri = soup_uri_new (priv->proxy_uri); + + if (soup_session) + g_object_set (G_OBJECT (soup_session), + "proxy-uri", uri, + NULL); + + if (uri) + g_object_unref (uri); + + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); } @@ -611,8 +623,13 @@ fill_tile (ChamplainMapSource *map_source, if (!soup_session) { - soup_session = soup_session_async_new_with_options ("proxy-uri", - soup_uri_new (priv->proxy_uri), + SoupURI *uri = NULL; + + if (priv->proxy_uri) + uri = soup_uri_new (priv->proxy_uri); + + soup_session = soup_session_async_new_with_options ( + "proxy-uri", uri, #ifdef HAVE_LIBSOUP_GNOME SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_PROXY_RESOLVER_GNOME, #endif @@ -622,6 +639,9 @@ fill_tile (ChamplainMapSource *map_source, "max-conns-per-host", 2, NULL); // This is as required by OSM g_object_add_weak_pointer (G_OBJECT (soup_session), (gpointer *) &soup_session); + + if (uri) + g_object_unref (uri); } uri = champlain_network_map_source_get_tile_uri (source, -- 2.39.5