map_poi_deinit(void)
{
map_poi_cache_clear();
+g_object_unref(poi_store);
#if 0
g_object_unref(layout);
g_object_unref(fontdesc);
void
map_poi_cache_clear(void)
{
-if (poi_store==NULL)
- return;
-
+g_return_if_fail(poi_store);
gtk_list_store_clear(poi_store);
-g_object_unref(G_OBJECT(poi_store));
-poi_store=NULL;
}
static gboolean
guint pois;
/* Reload POIs if we zoom out or have moved */
-if ((last_zoom<_zoom || prev_ux!=unitx || prev_uy!=unity) && poi_store!=NULL) {
+if (last_zoom<_zoom || prev_ux!=unitx || prev_uy!=unity) {
g_debug("Reloading POIs");
map_poi_cache_clear();
-} else {
- g_debug("Using cached POIs");
}
-if (poi_store==NULL) {
- if (poi_get_list_inside(lat1, lon1, lat2, lon2, &poi_store, &pois)==FALSE)
- return FALSE;
-}
+if (poi_get_list_inside(lat1, lon1, lat2, lon2, &poi_store, &pois)==FALSE)
+ return FALSE;
+
return TRUE;
}
if (_poi_zoom <= _zoom)
return FALSE;
-if (poi_store==NULL)
- return FALSE;
+g_return_val_if_fail(poi_store, FALSE);
valid=gtk_tree_model_get_iter_first(GTK_TREE_MODEL(poi_store), &iter);
-if (valid==FALSE)
- return FALSE;
+g_return_val_if_fail(valid, FALSE);
while (valid) {
gdouble tmp, plat, plon;
if (map_poi_reload_poi(unitx, unity, lat1, lon1, lat2, lon2)==FALSE)
return;
+g_assert(poi_store);
valid=gtk_tree_model_get_iter_first(GTK_TREE_MODEL(poi_store), &iter);
if (!valid)
return;
poi_db_prepare(sqlite3 *db)
{
/* Select POIs inside given minmax lat,lon */
-DB_PREP(db,
- "select "
+DB_PREP(db, "select "
POI_BASE_SQL_FIELDS
" from poi p, category c "
" where p.lat between ? and ? "
poisql.select_poi);
/* Get POI with given ID */
-DB_PREP(db,
- "select "
+DB_PREP(db, "select "
POI_BASE_SQL_FIELDS
" from poi p, category c "
" where p.poi_id = ? "
poisql.select_poi_by_id);
/* Search POIs by label and any category */
-DB_PREP(db,
- "select "
+DB_PREP(db, "select "
POI_BASE_SQL_FIELDS
" from poi p, category c "
" where p.lat between ? and ? "
poisql.select_poi_search);
/* Search POI by label and category */
-DB_PREP(db,
- "select "
+DB_PREP(db, "select "
POI_BASE_SQL_FIELDS
" from poi p, category c "
" where p.lat between ? and ? "
poisql.select_poi_search_cat);
/* Search POIs by category */
-DB_PREP(db,
- "select "
+DB_PREP(db, "select "
POI_BASE_SQL_FIELDS
" from poi p, category c "
" where p.lat between ? and ? "
poisql.select_poi_by_cat);
/* Select any nearest POI */
-DB_PREP(db,
- "select "
+DB_PREP(db, "select "
POI_MINI_SQL_FIELDS
" from poi p, category c "
" where c.enabled = 1 and p.cat_id = c.cat_id "
DB_PREP(db, "delete from poi where cat_id=?", poisql.delete_poi_by_catid);
/* select from category */
-DB_PREP(db,
- "select c.label, c.desc, c.enabled"
+DB_PREP(db, "select c.label, c.desc, c.enabled"
" from category c where c.cat_id = ?",
poisql.select_cat);
/* insert into category */
-DB_PREP(db,
- "insert into category (label, desc, enabled)"
+DB_PREP(db, "insert into category (label, desc, enabled)"
" values (?, ?, ?)",
poisql.insert_cat);
/* update category */
-DB_PREP(db,
- "update category set label = ?, desc = ?,"
+DB_PREP(db, "update category set label = ?, desc = ?,"
" enabled = ? where poi_id = ?",
poisql.update_cat);
/* delete from category */
DB_PREP(db,"delete from category where cat_id = ?",
poisql.delete_cat);
/* enable category */
-DB_PREP(db,
- "update category set enabled = ?"
+DB_PREP(db, "update category set enabled = ?"
" where cat_id = ?",
poisql.toggle_cat);
/* select all category */
-DB_PREP(db,
- "select c.cat_id, c.label, c.desc, c.enabled, c.icon, c.color,"
+DB_PREP(db, "select c.cat_id, c.label, c.desc, c.enabled, c.icon, c.color,"
" count(p.poi_id)"
" from category c"
" left outer join poi p on c.cat_id = p.cat_id"
" order by c.priority,c.label",
poisql.selall_cat);
/* Select quick categories */
-DB_PREP(db,
- "select c.cat_id, c.label, c.icon, c.color"
+DB_PREP(db, "select c.cat_id, c.label, c.icon, c.color"
" from category c where c.enabled=1 "
" order by c.priority,c.label limit 9",
poisql.select_quick_cat);
return FALSE;
}
-*store = poi_list_store_new();
+if (*store==NULL)
+ *store = poi_list_store_new();
while (SQLITE_ROW == sqlite3_step(sql)) {
gdouble rlat, rlon, dist;
return FALSE;
}
-*store = poi_list_store_new();
+if (*store==NULL)
+ *store = poi_list_store_new();
while (SQLITE_ROW == sqlite3_step(poisql.select_poi)) {
gdouble lat, lon, dist=0;