X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fplugins%2Fmap.c;h=0ae8ef6c411fadf497d7fa426547c8114a2f781b;hb=5350256efff1c97426e0db60e404bfd8a6cb08be;hp=c787224b16aff57efaea95eab21a4182ccea02f3;hpb=b5fde541db3eec5aa0b2d7f5b7a0725ad524f84c;p=grits diff --git a/src/plugins/map.c b/src/plugins/map.c index c787224..0ae8ef6 100644 --- a/src/plugins/map.c +++ b/src/plugins/map.c @@ -134,12 +134,12 @@ static gpointer _update_tiles(gpointer _map) { g_debug("GisPluginMap: _update_tiles"); GisPluginMap *map = _map; - g_mutex_lock(map->mutex); - gdouble lat, lon, elev; - gis_viewer_get_location(map->viewer, &lat, &lon, &elev); - gis_tile_update(map->tiles, + if (!g_mutex_trylock(map->mutex)) + return NULL; + GisPoint eye; + gis_viewer_get_location(map->viewer, &eye.lat, &eye.lon, &eye.elev); + gis_tile_update(map->tiles, &eye, MAX_RESOLUTION, TILE_WIDTH, TILE_WIDTH, - lat, lon, elev, _load_tile, map); gis_tile_gc(map->tiles, time(NULL)-10, _free_tile, map); @@ -156,6 +156,13 @@ static void _on_location_changed(GisViewer *viewer, g_thread_create(_update_tiles, map, FALSE, NULL); } +static gpointer _threaded_init(GisPluginMap *map) +{ + _load_tile(map->tiles, map); + _update_tiles(map); + return NULL; +} + /*********** * Methods * ***********/ @@ -174,8 +181,7 @@ GisPluginMap *gis_plugin_map_new(GisViewer *viewer) map->viewer = g_object_ref(viewer); /* Load initial tiles */ - _load_tile(map->tiles, map); - g_thread_create(_update_tiles, map, FALSE, NULL); + g_thread_create((GThreadFunc)_threaded_init, map, FALSE, NULL); /* Connect signals */ map->sigid = g_signal_connect(map->viewer, "location-changed",