From 94cfe6ac2c1a1f86d0d6ca8ce72714f4ae786692 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Mon, 10 Mar 2008 13:08:05 +0200 Subject: [PATCH] Some debuging stats and messages. --- src/poi.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/poi.c b/src/poi.c index 107fd92..b50674d 100644 --- a/src/poi.c +++ b/src/poi.c @@ -264,7 +264,7 @@ poi_db_prepare(sqlite3 *db) -1, &poisql.select_poi_by_id, NULL)!=SQLITE_OK) return FALSE; - /* Search POIs by label */ + /* Search POIs by label and any category */ if (sqlite3_prepare_v2(db, "select " POI_BASE_SQL_FIELDS @@ -275,7 +275,7 @@ poi_db_prepare(sqlite3 *db) -1, &poisql.select_poi_search, NULL)!=SQLITE_OK) return FALSE; - /* Search POI by label and specific category */ + /* Search POI by label and category */ if (sqlite3_prepare_v2(db, "select " POI_BASE_SQL_FIELDS @@ -286,7 +286,7 @@ poi_db_prepare(sqlite3 *db) -1, &poisql.select_poi_search_cat, NULL)!=SQLITE_OK) return FALSE; - /* Search specific category */ + /* Search POIs by category */ if (sqlite3_prepare_v2(db, "select " POI_BASE_SQL_FIELDS @@ -297,7 +297,7 @@ poi_db_prepare(sqlite3 *db) -1, &poisql.select_poi_by_cat, NULL)!=SQLITE_OK) return FALSE; - /* Select nearest POI */ + /* Select any nearest POI */ if (sqlite3_prepare_v2(db, "select " POI_MINI_SQL_FIELDS @@ -694,6 +694,7 @@ return TRUE; gboolean poi_get_list_inside(gdouble lat1, gdouble lon1, gdouble lat2, gdouble lon2, GtkListStore **store, guint *num_poi) { +static active=FALSE; GtkTreeIter iter; gchar tmp1[16], tmp2[16]; @@ -702,6 +703,10 @@ num_poi=0; if (!_db) return FALSE; +if (active) + return FALSE; + +active=TRUE; if (SQLITE_OK != sqlite3_bind_double(poisql.select_poi, 1, lat1) || SQLITE_OK != sqlite3_bind_double(poisql.select_poi, 2, lat2) || SQLITE_OK != sqlite3_bind_double(poisql.select_poi, 3, lon1) || @@ -738,6 +743,7 @@ while (SQLITE_ROW == sqlite3_step(poisql.select_poi)) { } sqlite3_reset(poisql.select_poi); sqlite3_clear_bindings(poisql.select_poi); +active=FALSE; return TRUE; } @@ -876,7 +882,9 @@ return NULL; GdkPixbuf * poi_get_icon(gchar *icon, gboolean big) { -gchar buffer[100]; +static guint hit=0; +static guint miss=0; +gchar buffer[256]; GdkPixbuf *pixbuf; GError *error = NULL; @@ -886,12 +894,18 @@ if (icon==NULL) if (strlen(icon)==0) return NULL; +g_debug("POI icon cache: %d / %d\n", hit, miss); + g_snprintf(buffer, sizeof(buffer), "%s/%s.%s/%s.png", theme_base, theme, (big==TRUE) ? "big" : "small", icon); +g_debug("Loading POI icon: %s", buffer); pixbuf=g_hash_table_lookup(poi_icon_hash, buffer); -if (pixbuf) +if (pixbuf) { + hit++; return pixbuf; +} +miss++; pixbuf=gdk_pixbuf_new_from_file(buffer, &error); -- 2.39.5