Commit 06a59b6b authored by Naba Kumar's avatar Naba Kumar

symbol-db: Return NULL for empty results and fixed GFile path

parent 6067fbc3
...@@ -46,6 +46,7 @@ struct _SymbolDBQueryResultPriv ...@@ -46,6 +46,7 @@ struct _SymbolDBQueryResultPriv
GdaDataModelIter *iter; GdaDataModelIter *iter;
const GHashTable *sym_type_conversion_hash; const GHashTable *sym_type_conversion_hash;
gchar *project_root; gchar *project_root;
gboolean result_is_empty;
}; };
static void isymbol_iface_init (IAnjutaSymbolIface *iface); static void isymbol_iface_init (IAnjutaSymbolIface *iface);
...@@ -102,6 +103,7 @@ sdb_query_result_init (SymbolDBQueryResult *result) ...@@ -102,6 +103,7 @@ sdb_query_result_init (SymbolDBQueryResult *result)
result->priv->col_map = g_new (gint, IANJUTA_SYMBOL_FIELD_END); result->priv->col_map = g_new (gint, IANJUTA_SYMBOL_FIELD_END);
for (i = 0; i < IANJUTA_SYMBOL_FIELD_END; i++) for (i = 0; i < IANJUTA_SYMBOL_FIELD_END; i++)
result->priv->col_map[i] = -1; result->priv->col_map[i] = -1;
result->priv->result_is_empty = TRUE;
} }
static void static void
...@@ -158,13 +160,15 @@ sdb_query_result_set_property (GObject *object, guint prop_id, ...@@ -158,13 +160,15 @@ sdb_query_result_set_property (GObject *object, guint prop_id,
} }
break; break;
case PROP_SDB_DATA_MODEL: case PROP_SDB_DATA_MODEL:
priv->result_is_empty = TRUE;
data_model = GDA_DATA_MODEL (g_value_get_object (value)); data_model = GDA_DATA_MODEL (g_value_get_object (value));
if (priv->data_model) g_object_unref (priv->data_model); if (priv->data_model) g_object_unref (priv->data_model);
priv->data_model = data_model; priv->data_model = data_model;
if (priv->iter) if (priv->iter)
g_object_unref (priv->iter); g_object_unref (priv->iter);
priv->iter = gda_data_model_create_iter (data_model); priv->iter = gda_data_model_create_iter (data_model);
gda_data_model_iter_move_at_row (priv->iter, 0); if (gda_data_model_iter_move_at_row (priv->iter, 0))
priv->result_is_empty = FALSE;
break; break;
case PROP_SDB_SYM_TYPE_CONVERSION_HASH: case PROP_SDB_SYM_TYPE_CONVERSION_HASH:
priv->sym_type_conversion_hash = g_value_get_pointer (value); priv->sym_type_conversion_hash = g_value_get_pointer (value);
...@@ -332,7 +336,9 @@ isymbol_get_file (IAnjutaSymbol *isymbol, GError **err) ...@@ -332,7 +336,9 @@ isymbol_get_file (IAnjutaSymbol *isymbol, GError **err)
{ {
SymbolDBQueryResult *result; SymbolDBQueryResult *result;
const gchar* file_path; const gchar* file_path;
gchar *abs_file_path;
GFile *file;
g_return_val_if_fail (SYMBOL_DB_IS_QUERY_RESULT (isymbol), NULL); g_return_val_if_fail (SYMBOL_DB_IS_QUERY_RESULT (isymbol), NULL);
result = SYMBOL_DB_QUERY_RESULT (isymbol); result = SYMBOL_DB_QUERY_RESULT (isymbol);
...@@ -340,8 +346,10 @@ isymbol_get_file (IAnjutaSymbol *isymbol, GError **err) ...@@ -340,8 +346,10 @@ isymbol_get_file (IAnjutaSymbol *isymbol, GError **err)
file_path = isymbol_get_string (isymbol, IANJUTA_SYMBOL_FIELD_FILE_PATH, err); file_path = isymbol_get_string (isymbol, IANJUTA_SYMBOL_FIELD_FILE_PATH, err);
if (!file_path) if (!file_path)
return NULL; return NULL;
abs_file_path = g_build_filename (result->priv->project_root, file_path, NULL);
return g_file_new_for_path (file_path); file = g_file_new_for_path (abs_file_path);
g_free (abs_file_path);
return file;
} }
static const GdkPixbuf* static const GdkPixbuf*
...@@ -504,3 +512,9 @@ symbol_db_query_result_new (GdaDataModel *data_model, ...@@ -504,3 +512,9 @@ symbol_db_query_result_new (GdaDataModel *data_model,
"project-root", project_root_dir, "project-root", project_root_dir,
NULL); NULL);
} }
gboolean
symbol_db_query_result_is_empty (SymbolDBQueryResult *result)
{
return result->priv->result_is_empty;
}
...@@ -61,6 +61,8 @@ SymbolDBQueryResult* symbol_db_query_result_new (GdaDataModel *data_model, ...@@ -61,6 +61,8 @@ SymbolDBQueryResult* symbol_db_query_result_new (GdaDataModel *data_model,
const GHashTable *sym_type_conversion_hash, const GHashTable *sym_type_conversion_hash,
const gchar *project_root_dir); const gchar *project_root_dir);
gboolean symbol_db_query_result_is_empty (SymbolDBQueryResult *result);
G_END_DECLS G_END_DECLS
#endif /* _SYMBOL_DB_QUERY_RESULT_H_ */ #endif /* _SYMBOL_DB_QUERY_RESULT_H_ */
...@@ -397,6 +397,11 @@ sdb_query_execute_real (SymbolDBQuery *query) ...@@ -397,6 +397,11 @@ sdb_query_execute_real (SymbolDBQuery *query)
priv->fields, priv->fields,
symbol_db_engine_get_type_conversion_hash (priv->dbe_selected), symbol_db_engine_get_type_conversion_hash (priv->dbe_selected),
symbol_db_engine_get_project_directory (priv->dbe_selected)); symbol_db_engine_get_project_directory (priv->dbe_selected));
if (symbol_db_query_result_is_empty (iter))
{
g_object_unref (iter);
return NULL;
}
return IANJUTA_ITERABLE (iter); return IANJUTA_ITERABLE (iter);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment