From cbfd0a96a0377ccecbed1863aba5284bb0e254dc Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Tue, 18 Mar 2008 21:34:27 +0200 Subject: [PATCH] Add g_return_val_if_fail for POI statements too. --- src/poi.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/poi.c b/src/poi.c index 3d106b0..c34ee3c 100644 --- a/src/poi.c +++ b/src/poi.c @@ -482,6 +482,8 @@ g_slice_free(poi_category, c); gboolean poi_category_toggle(guint cat_id, gboolean cat_enabled) { +g_return_val_if_fail(poisql.toggle_cat, FALSE); + if (SQLITE_OK != sqlite3_bind_int(poisql.toggle_cat, 1, cat_enabled) || SQLITE_OK != sqlite3_bind_int(poisql.toggle_cat, 2, cat_id) || SQLITE_DONE != sqlite3_step(poisql.toggle_cat)) { @@ -495,6 +497,7 @@ poi_category_get(guint cat_id, poi_category **c) { poi_category *cc; +g_return_val_if_fail(poisql.select_cat, FALSE); if (SQLITE_OK != sqlite3_bind_int(poisql.select_cat, 1, cat_id) || SQLITE_ROW != sqlite3_step(poisql.select_cat)) { sqlite3_reset(poisql.select_cat); return FALSE; @@ -520,6 +523,9 @@ gboolean results=TRUE; if (!_db) return FALSE; +g_return_val_if_fail(poisql.update_cat, FALSE); +g_return_val_if_fail(poisql.insert_cat, FALSE); + if (cat_id > 0) { /* edit category */ if (SQLITE_OK != sqlite3_bind_text(poisql.update_cat, 1, c->label, -1, SQLITE_STATIC) @@ -551,6 +557,9 @@ poi_category_delete(guint id) if (!poidb) return FALSE; +g_return_val_if_fail(poisql.delete_poi_by_catid, FALSE); +g_return_val_if_fail(poisql.delete_cat, FALSE); + if (SQLITE_OK != sqlite3_bind_int(poisql.delete_poi_by_catid, 1, id) || SQLITE_DONE != sqlite3_step(poisql.delete_poi_by_catid)) { sqlite3_reset(poisql.delete_poi_by_catid); return FALSE; @@ -574,6 +583,8 @@ poi_delete(guint id) if (!poidb) return FALSE; +g_return_val_if_fail(poisql.delete_poi, FALSE); + if (SQLITE_OK != sqlite3_bind_int(poisql.delete_poi, 1, id) || SQLITE_DONE != sqlite3_step(poisql.delete_poi)) { sqlite3_reset(poisql.delete_poi); return FALSE; @@ -596,6 +607,8 @@ guint range=1; if (!poidb) return FALSE; +g_return_val_if_fail(poisql.select_poi, FALSE); + g_printf("POI Search: [%s] around %.6f %.6f (%d %d)\n", text, lat, lon, cat, pst); switch (pst) { @@ -703,6 +716,8 @@ num_poi=0; if (!_db) return FALSE; +g_return_val_if_fail(poisql.select_poi, FALSE); + if (active) return FALSE; @@ -769,6 +784,8 @@ poi_get_by_id(guint id) { poi_info *p=NULL; +g_return_val_if_fail(poisql.select_poi_by_id, FALSE); + if (SQLITE_OK!=sqlite3_bind_double(poisql.select_poi_by_id, 1, id)) return NULL; @@ -801,6 +818,8 @@ poi_update(poi_info *p) if (!poidb) return FALSE; +g_return_val_if_fail(poisql.update_poi, FALSE); + if (p->poi_id==0) return FALSE; @@ -825,6 +844,8 @@ time_t t; if (!poidb) return FALSE; +g_return_val_if_fail(poisql.insert_poi, FALSE); + if (p->poi_id!=0) return FALSE; @@ -857,6 +878,8 @@ poi_info *p; if (!poidb) return FALSE; +g_return_val_if_fail(poisql.select_nearest_poi, FALSE); + sqlite3_reset(poisql.select_nearest_poi); sqlite3_clear_bindings(poisql.select_nearest_poi); @@ -925,6 +948,8 @@ GtkListStore *store; if (!poidb) return NULL; +g_return_val_if_fail(poisql.selall_cat, FALSE); + store=gtk_list_store_new(CAT_NUM_COLUMNS, /* pixbuf */ G_TYPE_UINT, G_TYPE_BOOLEAN, -- 2.39.5