X-Git-Url: http://pileus.org/git/?p=grits;a=blobdiff_plain;f=src%2Fplugins%2Fmap.c;h=13e91858d768a58a44e188396df4d6824de4d611;hp=a0f28dcc454b6b3e1952098e26095c81920622dc;hb=d8948985b467a5cfd0447ae413ed1c5d01afb024;hpb=ae53954e8d951923cac226f0c576449072480e84 diff --git a/src/plugins/map.c b/src/plugins/map.c index a0f28dc..13e9185 100644 --- a/src/plugins/map.c +++ b/src/plugins/map.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include "map.h" @@ -47,18 +47,28 @@ static const guchar colormap[][2][4] = { struct _LoadTileData { GisPluginMap *map; GisTile *tile; - GdkPixbuf *pixbuf; + gchar *path; }; static gboolean _load_tile_cb(gpointer _data) { struct _LoadTileData *data = _data; - GisPluginMap *map = data->map; - GisTile *tile = data->tile; - GdkPixbuf *pixbuf = data->pixbuf; + GisPluginMap *map = data->map; + GisTile *tile = data->tile; + gchar *path = data->path; g_free(data); - /* Create Texture */ + /* Load pixbuf */ g_debug("GisPluginMap: _load_tile_cb start"); + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, NULL); + if (!pixbuf) { + g_warning("GisPluginMap: _load_tile - Error loading pixbuf %s", path); + g_remove(path); + g_free(path); + return FALSE; + } + g_free(path); + + /* Create Texture */ guchar *pixels = gdk_pixbuf_get_pixels(pixbuf); gboolean alpha = gdk_pixbuf_get_has_alpha(pixbuf); gint width = gdk_pixbuf_get_width(pixbuf); @@ -102,18 +112,11 @@ static void _load_tile(GisTile *tile, gpointer _map) { GisPluginMap *map = _map; g_debug("GisPluginMap: _load_tile start %p", g_thread_self()); - char *path = gis_wms_fetch(map->wms, tile, GIS_ONCE, NULL, NULL); struct _LoadTileData *data = g_new0(struct _LoadTileData, 1); - data->map = map; - data->tile = tile; - data->pixbuf = gdk_pixbuf_new_from_file(path, NULL); - if (data->pixbuf) { - g_idle_add_full(G_PRIORITY_LOW, _load_tile_cb, data, NULL); - } else { - g_warning("GisPluginMap: _load_tile - Error loading pixbuf %s", path); - g_remove(path); - } - g_free(path); + data->map = map; + data->tile = tile; + data->path = gis_wms_fetch(map->wms, tile, GIS_ONCE, NULL, NULL); + g_idle_add_full(G_PRIORITY_LOW, _load_tile_cb, data, NULL); g_debug("GisPluginMap: _load_tile end %p", g_thread_self()); } @@ -125,9 +128,9 @@ static gboolean _free_tile_cb(gpointer data) } static void _free_tile(GisTile *tile, gpointer _map) { - GisPluginMap *map = _map; g_debug("GisPluginMap: _free_tile: %p", tile->data); - g_idle_add_full(G_PRIORITY_LOW, _free_tile_cb, tile->data, NULL); + if (tile->data) + g_idle_add_full(G_PRIORITY_LOW, _free_tile_cb, tile->data, NULL); } static gpointer _update_tiles(gpointer _map)