From: Pierre-Luc Beaudoin Date: Thu, 19 Mar 2009 07:02:47 +0000 (+0200) Subject: Fix Bug 575601: Return const gchar* insted of gchar* X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=00a6c784515ec29b69f36d15335ea8a127678a52;p=libchamplain Fix Bug 575601: Return const gchar* insted of gchar* Also took time to review the gchar types in Champlain*MapSource and ChamplainTile. Some other non const gchar were found. --- diff --git a/champlain/champlain-map-source.c b/champlain/champlain-map-source.c index 1359daa..62adcd6 100644 --- a/champlain/champlain-map-source.c +++ b/champlain/champlain-map-source.c @@ -384,7 +384,7 @@ champlain_map_source_get_name (ChamplainMapSource *map_source) void champlain_map_source_set_name (ChamplainMapSource *map_source, - const char *name) + const gchar *name) { ChamplainMapSourcePrivate *priv = GET_PRIVATE (map_source); @@ -400,7 +400,7 @@ champlain_map_source_get_license (ChamplainMapSource *map_source) void champlain_map_source_set_license (ChamplainMapSource *map_source, - const char *license) + const gchar *license) { ChamplainMapSourcePrivate *priv = GET_PRIVATE (map_source); diff --git a/champlain/champlain-map-source.h b/champlain/champlain-map-source.h index 796d5a3..2f8ddd9 100644 --- a/champlain/champlain-map-source.h +++ b/champlain/champlain-map-source.h @@ -91,11 +91,11 @@ void champlain_map_source_get_tile (ChamplainMapSource *map_source, ChamplainView *view, ChamplainZoomLevel *level, ChamplainTile *tile); void champlain_map_source_set_name (ChamplainMapSource *map_source, - const char *name); + const gchar *name); const gchar * champlain_map_source_get_name (ChamplainMapSource *map_source); void champlain_map_source_set_license (ChamplainMapSource *map_source, - const char *license); + const gchar *license); const gchar * champlain_map_source_get_license (ChamplainMapSource *map_source); diff --git a/champlain/champlain-network-map-source.c b/champlain/champlain-network-map-source.c index 6ede397..ce04fe3 100644 --- a/champlain/champlain-network-map-source.c +++ b/champlain/champlain-network-map-source.c @@ -207,14 +207,14 @@ champlain_network_map_source_init (ChamplainNetworkMapSource *champlainMapSource } ChamplainNetworkMapSource* -champlain_network_map_source_new_full (gchar *name, - gchar *license, - gchar *license_uri, +champlain_network_map_source_new_full (const gchar *name, + const gchar *license, + const gchar *license_uri, guint min_zoom, guint max_zoom, guint tile_size, ChamplainMapProjection projection, - gchar *uri_format) + const gchar *uri_format) { ChamplainNetworkMapSource * network_map_source; network_map_source = g_object_new (CHAMPLAIN_TYPE_NETWORK_MAP_SOURCE, "name", name, @@ -225,7 +225,7 @@ champlain_network_map_source_new_full (gchar *name, return network_map_source; } -gchar * +const gchar * champlain_network_map_source_get_tile_uri (ChamplainNetworkMapSource *network_map_source, gint x, gint y, @@ -380,7 +380,8 @@ file_loaded_cb (SoupSession *session, FileLoadedCallbackContext *ctx = (FileLoadedCallbackContext*) user_data; GdkPixbufLoader* loader; GError *error = NULL; - gchar* path = NULL, *filename = NULL; + gchar* path = NULL; + const gchar *filename = NULL; if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { @@ -438,7 +439,6 @@ file_loaded_cb (SoupSession *session, /*if (tile->to_destroy) { g_object_unref (loader); - g_free (filename); g_free (map_filename); g_free (tile); return; @@ -521,7 +521,7 @@ champlain_network_map_source_get_tile (ChamplainMapSource *map_source, else if (!priv->offline) { SoupMessage *msg; - gchar *uri; + const gchar *uri; FileLoadedCallbackContext *ctx = g_new0 (FileLoadedCallbackContext, 1); ctx->view = view; ctx->zoom_level = zoom_level; diff --git a/champlain/champlain-network-map-source.h b/champlain/champlain-network-map-source.h index 1eb31f6..5009d54 100644 --- a/champlain/champlain-network-map-source.h +++ b/champlain/champlain-network-map-source.h @@ -52,9 +52,10 @@ struct _ChamplainNetworkMapSourceClass GType champlain_network_map_source_get_type (void); -ChamplainNetworkMapSource* champlain_network_map_source_new_full (gchar *name, - gchar *license, gchar *license_uri, guint min_zoom, guint map_zoom, - guint tile_size, ChamplainMapProjection projection, gchar *uri_format); +ChamplainNetworkMapSource* champlain_network_map_source_new_full ( + const gchar *name, const gchar *license, const gchar *license_uri, + guint min_zoom, guint map_zoom, guint tile_size, + ChamplainMapProjection projection, const gchar *uri_format); ChamplainMapSource * champlain_map_source_new_osm_mapnik (void); ChamplainMapSource * champlain_map_source_new_osm_cyclemap (void); @@ -62,7 +63,7 @@ ChamplainMapSource * champlain_map_source_new_osm_osmarender (void); ChamplainMapSource * champlain_map_source_new_oam (void); ChamplainMapSource * champlain_map_source_new_mff_relief (void); -gchar * champlain_network_map_source_get_tile_uri (ChamplainNetworkMapSource *source, +const gchar * champlain_network_map_source_get_tile_uri (ChamplainNetworkMapSource *source, gint x, gint y, gint z); void champlain_network_map_source_set_tile_uri (ChamplainNetworkMapSource *network_map_source, diff --git a/champlain/champlain-tile.c b/champlain/champlain-tile.c index 75344ec..04dfc16 100644 --- a/champlain/champlain-tile.c +++ b/champlain/champlain-tile.c @@ -124,10 +124,10 @@ champlain_tile_set_property (GObject *object, champlain_tile_set_state (self, g_value_get_enum (value)); break; case PROP_URI: - champlain_tile_set_uri (self, g_value_dup_string (value)); + champlain_tile_set_uri (self, g_value_get_string (value)); break; case PROP_FILENAME: - champlain_tile_set_filename (self, g_value_dup_string (value)); + champlain_tile_set_filename (self, g_value_get_string (value)); break; case PROP_ACTOR: champlain_tile_set_actor (self, g_value_get_object (value)); @@ -151,6 +151,11 @@ champlain_tile_dispose (GObject *object) static void champlain_tile_finalize (GObject *object) { + ChamplainTilePrivate *priv = GET_PRIVATE (object); + + g_free (priv->uri); + g_free (priv->filename); + G_OBJECT_CLASS (champlain_tile_parent_class)->finalize (object); } @@ -309,7 +314,7 @@ champlain_tile_get_state (ChamplainTile *self) return priv->state; } -gchar * +const gchar * champlain_tile_get_uri (ChamplainTile *self) { g_return_val_if_fail(CHAMPLAIN_TILE(self), NULL); @@ -319,7 +324,7 @@ champlain_tile_get_uri (ChamplainTile *self) return priv->uri; } -gchar * +const gchar * champlain_tile_get_filename (ChamplainTile *self) { g_return_val_if_fail(CHAMPLAIN_TILE(self), NULL); @@ -405,26 +410,28 @@ champlain_tile_new_full (gint x, } void -champlain_tile_set_uri (ChamplainTile *self, gchar *uri) +champlain_tile_set_uri (ChamplainTile *self, + const gchar *uri) { g_return_if_fail(CHAMPLAIN_TILE(self)); g_return_if_fail(uri != NULL); ChamplainTilePrivate *priv = GET_PRIVATE (self); - priv->uri = uri; + priv->uri = g_strdup (uri); g_object_notify (G_OBJECT (self), "uri"); } void -champlain_tile_set_filename (ChamplainTile *self, gchar *filename) +champlain_tile_set_filename (ChamplainTile *self, + const gchar *filename) { g_return_if_fail(CHAMPLAIN_TILE(self)); g_return_if_fail(filename != NULL); ChamplainTilePrivate *priv = GET_PRIVATE (self); - priv->filename = filename; + priv->filename = g_strdup (filename); g_object_notify (G_OBJECT (self), "filename"); } diff --git a/champlain/champlain-tile.h b/champlain/champlain-tile.h index 177b28a..743cd7b 100644 --- a/champlain/champlain-tile.h +++ b/champlain/champlain-tile.h @@ -61,8 +61,8 @@ gint champlain_tile_get_y (ChamplainTile *self); gint champlain_tile_get_zoom_level (ChamplainTile *self); guint champlain_tile_get_size (ChamplainTile *self); ChamplainState champlain_tile_get_state (ChamplainTile *self); -gchar * champlain_tile_get_uri (ChamplainTile *self); -gchar * champlain_tile_get_filename (ChamplainTile *self); +const gchar * champlain_tile_get_uri (ChamplainTile *self); +const gchar * champlain_tile_get_filename (ChamplainTile *self); ClutterActor * champlain_tile_get_actor (ChamplainTile *self); void champlain_tile_set_x (ChamplainTile *self, gint x); @@ -70,8 +70,8 @@ void champlain_tile_set_y (ChamplainTile *self, gint y); void champlain_tile_set_zoom_level (ChamplainTile *self, gint zoom_level); void champlain_tile_set_size (ChamplainTile *self, guint size); void champlain_tile_set_state (ChamplainTile *self, ChamplainState state); -void champlain_tile_set_uri (ChamplainTile *self, gchar* uri); -void champlain_tile_set_filename (ChamplainTile *self, gchar* filename); +void champlain_tile_set_uri (ChamplainTile *self, const gchar *uri); +void champlain_tile_set_filename (ChamplainTile *self, const gchar *filename); void champlain_tile_set_actor (ChamplainTile *self, ClutterActor* actor); G_END_DECLS