Commit f2a57a4b authored by Massimo Cora's avatar Massimo Cora

Splitted interfaces for searching symbols. Now you can search in system,

	* libanjuta/interfaces/libanjuta.idl:
	* plugins/symbol-db/plugin.c (do_import_system_sources),
	(on_project_root_added), (isymbol_manager_search),
	(isymbol_manager_get_members), (isymbol_manager_search_system),
	(isymbol_manager_search_project), (isymbol_manager_search_file),
	(isymbol_manager_iface_init):
	* plugins/symbol-db/symbol-db-engine-core.c (sdb_engine_init),
	(symbol_db_engine_file_exists),
	(symbol_db_engine_add_new_workspace),
	(symbol_db_engine_project_exists),
	(symbol_db_engine_add_new_project), (sdb_engine_add_new_db_file),
	(symbol_db_engine_update_project_symbols),
	(symbol_db_engine_remove_file), (on_scan_update_buffer_end),
	(symbol_db_engine_update_buffer_symbols):
	* plugins/symbol-db/symbol-db-engine-priv.h:
	* plugins/symbol-db/symbol-db-engine-queries.c
	(symbol_db_engine_get_current_scope),
	(symbol_db_engine_get_file_symbols),
	(symbol_db_engine_find_symbol_by_name_pattern_on_file):
	* plugins/symbol-db/symbol-db-engine-queries.h:
	* plugins/symbol-db/symbol-db-engine-utils.c
	(symbol_db_util_get_full_local_path),
	(symbol_db_util_get_file_db_path),
	(symbol_db_util_get_files_with_zero_symbols),
	(symbol_db_util_is_pattern_exact_match),
	(symbol_db_util_fill_type_array),
	(symbol_db_util_get_sym_type_conversion_hash):
	* plugins/symbol-db/symbol-db-engine-utils.h:
	* plugins/symbol-db/symbol-db-view-locals.c
	(symbol_db_view_locals_update_list):
	* plugins/symbol-db/symbol-db-view-search.c
	(sdb_view_search_model_filter):
	Splitted interfaces for searching symbols. Now you can search in system,
	project or file.
	#566987 – display tooltip with prototype when calling function in project
	Fixed some lock () issues.

svn path=/trunk/; revision=4693
parent 95f5842c
2009-02-03 Massimo Cora' <mcora@svn.gnome.org>
* libanjuta/interfaces/libanjuta.idl:
* plugins/symbol-db/plugin.c (do_import_system_sources),
(on_project_root_added), (isymbol_manager_search),
(isymbol_manager_get_members), (isymbol_manager_search_system),
(isymbol_manager_search_project), (isymbol_manager_search_file),
(isymbol_manager_iface_init):
* plugins/symbol-db/symbol-db-engine-core.c (sdb_engine_init),
(symbol_db_engine_file_exists),
(symbol_db_engine_add_new_workspace),
(symbol_db_engine_project_exists),
(symbol_db_engine_add_new_project), (sdb_engine_add_new_db_file),
(symbol_db_engine_update_project_symbols),
(symbol_db_engine_remove_file), (on_scan_update_buffer_end),
(symbol_db_engine_update_buffer_symbols):
* plugins/symbol-db/symbol-db-engine-priv.h:
* plugins/symbol-db/symbol-db-engine-queries.c
(symbol_db_engine_get_current_scope),
(symbol_db_engine_get_file_symbols),
(symbol_db_engine_find_symbol_by_name_pattern_on_file):
* plugins/symbol-db/symbol-db-engine-queries.h:
* plugins/symbol-db/symbol-db-engine-utils.c
(symbol_db_util_get_full_local_path),
(symbol_db_util_get_file_db_path),
(symbol_db_util_get_files_with_zero_symbols),
(symbol_db_util_is_pattern_exact_match),
(symbol_db_util_fill_type_array),
(symbol_db_util_get_sym_type_conversion_hash):
* plugins/symbol-db/symbol-db-engine-utils.h:
* plugins/symbol-db/symbol-db-view-locals.c
(symbol_db_view_locals_update_list):
* plugins/symbol-db/symbol-db-view-search.c
(sdb_view_search_model_filter):
Splitted interfaces for searching symbols. Now you can search in system,
project or file.
#566987 – display tooltip with prototype when calling function in project
Fixed some lock () issues.
=== 2.25.901 === === 2.25.901 ===
2009-02-03 Johannes Schmid <jhs@gnome.org> 2009-02-03 Johannes Schmid <jhs@gnome.org>
...@@ -497,7 +497,7 @@ interface IAnjutaIterable ...@@ -497,7 +497,7 @@ interface IAnjutaIterable
* @obj: Self * @obj: Self
* @err: Error propagation and reporting * @err: Error propagation and reporting
* *
* Clones the iterable. The returned iterable object must be unrefed * Clones the iterable. The returned iterable object must be unreffed
* when done. * when done.
* *
* Returns: A new instance of this iterable pointing at the same location. * Returns: A new instance of this iterable pointing at the same location.
...@@ -5030,20 +5030,84 @@ interface IAnjutaSymbolManager ...@@ -5030,20 +5030,84 @@ interface IAnjutaSymbolManager
* @global_symbols_search: if TRUE it will search only for public/extern functions. * @global_symbols_search: if TRUE it will search only for public/extern functions.
* If FALSE it will search also for static/private functions. * If FALSE it will search also for static/private functions.
* @global_tags_search: If TRUE it'll search only for system tags, using pkg-config to retrieve installed packages * @global_tags_search: If TRUE it'll search only for system tags, using pkg-config to retrieve installed packages
* infos. If FALSE only current project's symbols will be searched. * info. If FALSE only current project's symbols will be searched.
* @results_limit: Limit results to an upper bound. -1 If you don't want to use this par. * @results_limit: Limit results to an upper bound. -1 If you don't want to use this par.
* @results_offset: Skip results_offset results. -1 If you don't want to use this par. * @results_offset: Skip results_offset results. -1 If you don't want to use this par.
* @results_limit Limit results to an upper bound. -1 If you don't want to use this par.
* @results_offset Skip results_offset results. -1 If you don't want to use this par.
* @err: Error propagation and reporting. * @err: Error propagation and reporting.
* @deprecated This function is deprecated and should not be used in new code.
* *
* Database query. The returned #IAnjutaIterable object must be unrefed after use. * Database query. The returned #IAnjutaIterable object must be unreffed after use.
* *
* Returns: an iteratable object, or NULL if error occurs or if no symbols are found. * Returns: an iteratable object, or NULL if error occurs or if no symbols are found.
* *
*/ */
IAnjutaIterable* search (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *match_name, gboolean partial_name_match, gboolean global_symbols_search, gboolean global_tags_search, gint results_limit, gint results_offset); IAnjutaIterable* search (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *match_name, gboolean partial_name_match, gboolean global_symbols_search, gboolean global_tags_search, gint results_limit, gint results_offset);
/**
* ianjuta_symbol_manager_search_system:
* @obj: Self
* @match_types: If passed #IANJUTA_SYMBOL_TYPE_MAX the function will not perfom any filter.
* @include_types: Should the result contain or exclude the match_types? TRUE to include them,
* FALSE to exclude. For example use may want all symbols but classes.
* @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @pattern Pattern you want to search for. It can me something like 'foo_func' (exact match)
* or something like 'foo_fun%' (LIKE match, matching all the symbol prefixed with 'foo_fun'
* @results_limit: Limit results to an upper bound. -1 If you don't want to use this par.
* @results_offset: Skip results_offset results. -1 If you don't want to use this par.
* @err: Error propagation and reporting.
*
* Database query. The returned #IAnjutaIterable object must be unreffed after use.
* The search is case sensitive. Symbols are searched in global (system) packages.
* User must have installed the -dev packages of, for istance, gtk+, glib, etc.
*
* Returns: an iteratable object, or NULL if error occurs or if no symbols are found.
*
*/
IAnjutaIterable* search_system (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern, gint results_limit, gint results_offset);
/**
* ianjuta_symbol_manager_search_project:
* @obj: Self
* @match_types: If passed #IANJUTA_SYMBOL_TYPE_MAX the function will not perfom any filter.
* @include_types: Should the result contain or exclude the match_types? TRUE to include them,
* FALSE to exclude. For example use may want all symbols but classes.
* @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @pattern Pattern you want to search for. It can me something like 'foo_func' (exact match)
* or something like 'foo_fun%' (LIKE match, matching all the symbol prefixed with 'foo_fun'
* @results_limit: Limit results to an upper bound. -1 If you don't want to use this par.
* @results_offset: Skip results_offset results. -1 If you don't want to use this par.
* @err: Error propagation and reporting.
*
* Database query. The returned #IAnjutaIterable object must be unreffed after use.
* The search is case sensitive. Symbols are searched in current opened project.
*
* Returns: an iteratable object, or NULL if error occurs or if no symbols are found.
*
*/
IAnjutaIterable* search_project (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern, gint results_limit, gint results_offset);
/**
* ianjuta_symbol_manager_search_project:
* @obj: Self
* @match_types: If passed #IANJUTA_SYMBOL_TYPE_MAX the function will not perfom any filter.
* @include_types: Should the result contain or exclude the match_types? TRUE to include them,
* FALSE to exclude. For example use may want all symbols but classes.
* @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @pattern Pattern you want to search for. It can me something like 'foo_func' (exact match)
* or something like 'foo_fun%' (LIKE match, matching all the symbol prefixed with 'foo_fun'
* @file GFile of the file, belonging to the project, which you want to scan symbols for.
* @results_limit: Limit results to an upper bound. -1 If you don't want to use this par.
* @results_offset: Skip results_offset results. -1 If you don't want to use this par.
* @err: Error propagation and reporting.
*
* Database query. The returned #IAnjutaIterable object must be unreffed after use.
* The search is case sensitive. Symbols are searched in the specified file.
*
* Returns: an iteratable object, or NULL if error occurs or if no symbols are found.
*
*/
IAnjutaIterable* search_file (IAnjutaSymbolType match_types, gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern, const GFile *file, gint results_limit, gint results_offset);
/** /**
* ianjuta_symbol_manager_get_members: * ianjuta_symbol_manager_get_members:
* @obj: Self * @obj: Self
...@@ -5051,7 +5115,7 @@ interface IAnjutaSymbolManager ...@@ -5051,7 +5115,7 @@ interface IAnjutaSymbolManager
* @global_search: fixme * @global_search: fixme
* @err: Error propagation and reporting. * @err: Error propagation and reporting.
* *
* Database query. The returned #IAnjutaIterable object must be unrefed after use. * Database query. The returned #IAnjutaIterable object must be unreffed after use.
* *
* Returns: an iteratable object, or NULL if error occurs or if no symbols are found. * Returns: an iteratable object, or NULL if error occurs or if no symbols are found.
* *
...@@ -5065,7 +5129,7 @@ interface IAnjutaSymbolManager ...@@ -5065,7 +5129,7 @@ interface IAnjutaSymbolManager
* @info_fields: Kind of infos you would like to have available on the resulting Symbols. * @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @err: Error propagation and reporting. * @err: Error propagation and reporting.
* *
* Database query. The returned #IAnjutaIterable object must be unrefed after use. * Database query. The returned #IAnjutaIterable object must be unreffed after use.
* *
* Returns: if the passed symbol is a class then this function tries to catch its parents. * Returns: if the passed symbol is a class then this function tries to catch its parents.
* *
...@@ -5080,7 +5144,7 @@ interface IAnjutaSymbolManager ...@@ -5080,7 +5144,7 @@ interface IAnjutaSymbolManager
* @info_fields: Kind of infos you would like to have available on the resulting Symbols. * @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @err: Error propagation and reporting. * @err: Error propagation and reporting.
* *
* Database query. The returned #IAnjutaIterable object must be unrefed after use. * Database query. The returned #IAnjutaIterable object must be unreffed after use.
* It gets the scope specified by the line of the file. * It gets the scope specified by the line of the file.
* *
* Returns: The returned iterator should contain just one element if the query is successful, * Returns: The returned iterator should contain just one element if the query is successful,
...@@ -5097,12 +5161,12 @@ interface IAnjutaSymbolManager ...@@ -5097,12 +5161,12 @@ interface IAnjutaSymbolManager
* @info_fields: Kind of infos you would like to have available on the resulting Symbols. * @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @err: Error propagation and reporting. * @err: Error propagation and reporting.
* *
* Database query. The returned #IAnjutaIterable object must be unrefed after use. * Database query. The returned #IAnjutaIterable object must be unreffed after use.
* Find the parent scope given a symbol * Find the parent scope given a symbol
* *
* Returns: The returned #IAnjutaIterable object should contain just one element if the * Returns: The returned #IAnjutaIterable object should contain just one element if the
* query is successful, no element or NULL is returned if function went wrong. * query is successful, no element or NULL is returned if function went wrong.
* The returned #IAnjutaIterable object must be unrefed after use. * The returned #IAnjutaIterable object must be unreffed after use.
*/ */
IAnjutaIterable* get_parent_scope (const IAnjutaSymbol *symbol, const gchar *filename, IAnjutaSymbolField info_fields); IAnjutaIterable* get_parent_scope (const IAnjutaSymbol *symbol, const gchar *filename, IAnjutaSymbolField info_fields);
...@@ -5113,7 +5177,7 @@ interface IAnjutaSymbolManager ...@@ -5113,7 +5177,7 @@ interface IAnjutaSymbolManager
* @info_fields: Kind of infos you would like to have available on the resulting Symbols. * @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @err: Error propagation and reporting. * @err: Error propagation and reporting.
* *
* Database query. The returned #IAnjutaIterable object must be unrefed after use. * Database query. The returned #IAnjutaIterable object must be unreffed after use.
* While at first sight this function may seem as useless, in a deeper inspection * While at first sight this function may seem as useless, in a deeper inspection
* you can see that you can achieve speed improvements for example avoiding * you can see that you can achieve speed improvements for example avoiding
* to pass many info_fields requests to a search query, which itself could require * to pass many info_fields requests to a search query, which itself could require
...@@ -5122,7 +5186,7 @@ interface IAnjutaSymbolManager ...@@ -5122,7 +5186,7 @@ interface IAnjutaSymbolManager
* *
* Returns: The returned #IAnjutaIterable object should contain just one element if the * Returns: The returned #IAnjutaIterable object should contain just one element if the
* query is successful, no element or NULL is returned if function went wrong. * query is successful, no element or NULL is returned if function went wrong.
* The returned #IAnjutaIterable object must be unrefed after use. * The returned #IAnjutaIterable object must be unreffed after use.
* *
*/ */
IAnjutaIterable* get_symbol_more_info (const IAnjutaSymbol *symbol, IAnjutaSymbolField info_fields); IAnjutaIterable* get_symbol_more_info (const IAnjutaSymbol *symbol, IAnjutaSymbolField info_fields);
...@@ -5134,13 +5198,13 @@ interface IAnjutaSymbolManager ...@@ -5134,13 +5198,13 @@ interface IAnjutaSymbolManager
* @info_fields: Kind of infos you would like to have available on the resulting Symbols. * @info_fields: Kind of infos you would like to have available on the resulting Symbols.
* @return NULL on error. * @return NULL on error.
* *
* Database query. The returned #IAnjutaIterable object must be unrefed after use. * Database query. The returned #IAnjutaIterable object must be unreffed after use.
* A symbol is identified by an unique id. If you have its id you can also * A symbol is identified by an unique id. If you have its id you can also
* have its object IAnjutaSymbol. * have its object IAnjutaSymbol.
* *
* Returns: The returned #IAnjutaIterable object should contain just one element if the * Returns: The returned #IAnjutaIterable object should contain just one element if the
* query is successful, no element or NULL is returned if function went wrong. * query is successful, no element or NULL is returned if function went wrong.
* The returned #IAnjutaIterable object must be unrefed after use. * The returned #IAnjutaIterable object must be unreffed after use.
*/ */
IAnjutaSymbol* get_symbol_by_id (gint symbol_id, IAnjutaSymbolField info_fields); IAnjutaSymbol* get_symbol_by_id (gint symbol_id, IAnjutaSymbolField info_fields);
} }
......
...@@ -1502,7 +1502,7 @@ do_import_system_sources (SymbolDBPlugin *sdb_plugin) ...@@ -1502,7 +1502,7 @@ do_import_system_sources (SymbolDBPlugin *sdb_plugin)
/* the resume thing */ /* the resume thing */
GPtrArray *sys_src_array = NULL; GPtrArray *sys_src_array = NULL;
sys_src_array = sys_src_array =
symbol_db_engine_get_files_with_zero_symbols (sdb_plugin->sdbe_globals); symbol_db_util_get_files_with_zero_symbols (sdb_plugin->sdbe_globals);
if (sys_src_array != NULL && sys_src_array->len > 0) if (sys_src_array != NULL && sys_src_array->len > 0)
{ {
...@@ -1874,7 +1874,7 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name, ...@@ -1874,7 +1874,7 @@ on_project_root_added (AnjutaPlugin *plugin, const gchar *name,
sources_array = sources_array =
symbol_db_engine_get_files_with_zero_symbols (sdb_plugin->sdbe_project); symbol_db_util_get_files_with_zero_symbols (sdb_plugin->sdbe_project);
if (sources_array != NULL && sources_array->len > 0) if (sources_array != NULL && sources_array->len > 0)
{ {
...@@ -2577,7 +2577,7 @@ isymbol_manager_search (IAnjutaSymbolManager *sm, ...@@ -2577,7 +2577,7 @@ isymbol_manager_search (IAnjutaSymbolManager *sm,
} }
else else
{ {
filter_array = symbol_db_engine_fill_type_array (match_types); filter_array = symbol_db_util_fill_type_array (match_types);
/*DEBUG_PRINT ("filter_array filled with %d kinds", filter_array->len);*/ /*DEBUG_PRINT ("filter_array filled with %d kinds", filter_array->len);*/
} }
...@@ -2629,7 +2629,6 @@ isymbol_manager_get_members (IAnjutaSymbolManager *sm, ...@@ -2629,7 +2629,6 @@ isymbol_manager_get_members (IAnjutaSymbolManager *sm,
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm); sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project); dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
node = SYMBOL_DB_ENGINE_ITERATOR_NODE (symbol); node = SYMBOL_DB_ENGINE_ITERATOR_NODE (symbol);
sym_id = symbol_db_engine_iterator_node_get_symbol_id (node); sym_id = symbol_db_engine_iterator_node_get_symbol_id (node);
...@@ -2770,6 +2769,134 @@ isymbol_manager_get_symbol_by_id (IAnjutaSymbolManager *sm, ...@@ -2770,6 +2769,134 @@ isymbol_manager_get_symbol_by_id (IAnjutaSymbolManager *sm,
return IANJUTA_SYMBOL (node); return IANJUTA_SYMBOL (node);
} }
static IAnjutaIterable*
isymbol_manager_search_system (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types,
gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern,
gint results_limit, gint results_offset, GError **err)
{
SymbolDBPlugin *sdb_plugin;
SymbolDBEngine *dbe;
SymbolDBEngineIterator *iterator;
gboolean exact_match;
GPtrArray *filter_array;
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_globals);
exact_match = symbol_db_util_is_pattern_exact_match (pattern);
if (match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
{
filter_array = NULL;
}
else
{
filter_array = symbol_db_util_fill_type_array (match_types);
}
iterator =
symbol_db_engine_find_symbol_by_name_pattern_filtered (dbe,
pattern,
exact_match,
filter_array,
include_types,
TRUE,
sdb_plugin->session_packages,
results_limit,
results_offset,
info_fields);
return IANJUTA_ITERABLE (iterator);
}
static IAnjutaIterable*
isymbol_manager_search_project (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types,
gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern,
gint results_limit, gint results_offset, GError **err)
{
SymbolDBPlugin *sdb_plugin;
SymbolDBEngine *dbe;
SymbolDBEngineIterator *iterator;
gboolean exact_match;
GPtrArray *filter_array;
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
exact_match = symbol_db_util_is_pattern_exact_match (pattern);
if (match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
{
filter_array = NULL;
}
else
{
filter_array = symbol_db_util_fill_type_array (match_types);
}
iterator =
symbol_db_engine_find_symbol_by_name_pattern_filtered (dbe,
pattern,
exact_match,
filter_array,
include_types,
FALSE,
NULL,
results_limit,
results_offset,
info_fields);
return IANJUTA_ITERABLE (iterator);
}
static IAnjutaIterable*
isymbol_manager_search_file (IAnjutaSymbolManager *sm, IAnjutaSymbolType match_types,
gboolean include_types, IAnjutaSymbolField info_fields, const gchar *pattern,
const GFile *file, gint results_limit, gint results_offset, GError **err)
{
SymbolDBPlugin *sdb_plugin;
SymbolDBEngine *dbe;
SymbolDBEngineIterator *iterator;
GPtrArray *filter_array;
gchar *abs_file_path;
sdb_plugin = ANJUTA_PLUGIN_SYMBOL_DB (sm);
dbe = SYMBOL_DB_ENGINE (sdb_plugin->sdbe_project);
abs_file_path = g_file_get_path ((GFile *)file);
if (abs_file_path == NULL)
{
g_warning ("isymbol_manager_search_file (): GFile has no absolute path");
return NULL;
}
if (match_types & IANJUTA_SYMBOL_TYPE_UNDEF)
{
filter_array = NULL;
}
else
{
filter_array = symbol_db_util_fill_type_array (match_types);
}
iterator =
symbol_db_engine_find_symbol_by_name_pattern_on_file (dbe,
pattern,
abs_file_path,
filter_array,
include_types,
results_limit,
results_offset,
info_fields);
g_free (abs_file_path);
return IANJUTA_ITERABLE (iterator);
}
static void static void
isymbol_manager_iface_init (IAnjutaSymbolManagerIface *iface) isymbol_manager_iface_init (IAnjutaSymbolManagerIface *iface)
{ {
...@@ -2780,6 +2907,9 @@ isymbol_manager_iface_init (IAnjutaSymbolManagerIface *iface) ...@@ -2780,6 +2907,9 @@ isymbol_manager_iface_init (IAnjutaSymbolManagerIface *iface)
iface->get_parent_scope = isymbol_manager_get_parent_scope; iface->get_parent_scope = isymbol_manager_get_parent_scope;
iface->get_symbol_more_info = isymbol_manager_get_symbol_more_info; iface->get_symbol_more_info = isymbol_manager_get_symbol_more_info;
iface->get_symbol_by_id = isymbol_manager_get_symbol_by_id; iface->get_symbol_by_id = isymbol_manager_get_symbol_by_id;
iface->search_system = isymbol_manager_search_system;
iface->search_project = isymbol_manager_search_project;
iface->search_file = isymbol_manager_search_file;
} }
......
...@@ -2362,6 +2362,10 @@ sdb_engine_init (SymbolDBEngine * object) ...@@ -2362,6 +2362,10 @@ sdb_engine_init (SymbolDBEngine * object)
DYN_PREP_QUERY_FIND_SYMBOL_BY_NAME_PATTERN_FILTERED, DYN_PREP_QUERY_FIND_SYMBOL_BY_NAME_PATTERN_FILTERED,
TRUE); TRUE);
DYN_QUERY_POPULATE_INIT_NODE(sdbe->priv->dyn_query_list,
DYN_PREP_QUERY_FIND_SYMBOL_BY_NAME_PATTERN_FILE,
TRUE);
DYN_QUERY_POPULATE_INIT_NODE(sdbe->priv->dyn_query_list, DYN_QUERY_POPULATE_INIT_NODE(sdbe->priv->dyn_query_list,
DYN_PREP_QUERY_GET_SCOPE_MEMBERS_BY_SYMBOL_ID, DYN_PREP_QUERY_GET_SCOPE_MEMBERS_BY_SYMBOL_ID,
TRUE); TRUE);
...@@ -2874,7 +2878,7 @@ symbol_db_engine_file_exists (SymbolDBEngine * dbe, const gchar * abs_file_path) ...@@ -2874,7 +2878,7 @@ symbol_db_engine_file_exists (SymbolDBEngine * dbe, const gchar * abs_file_path)
SDB_LOCK(priv); SDB_LOCK(priv);
relative = symbol_db_engine_get_file_db_path (dbe, abs_file_path); relative = symbol_db_util_get_file_db_path (dbe, abs_file_path);
if (relative == NULL) if (relative == NULL)
{ {
SDB_UNLOCK(priv); SDB_UNLOCK(priv);
...@@ -2970,6 +2974,7 @@ symbol_db_engine_open_db (SymbolDBEngine * dbe, const gchar * base_db_path, ...@@ -2970,6 +2974,7 @@ symbol_db_engine_open_db (SymbolDBEngine * dbe, const gchar * base_db_path,
return TRUE; return TRUE;
} }
/* ~~~ Thread note: this function locks the mutex ~~~ */
gboolean gboolean
symbol_db_engine_add_new_workspace (SymbolDBEngine * dbe, symbol_db_engine_add_new_workspace (SymbolDBEngine * dbe,
const gchar * workspace_name) const gchar * workspace_name)
...@@ -2992,10 +2997,13 @@ CREATE TABLE workspace (workspace_id integer PRIMARY KEY AUTOINCREMENT, ...@@ -2992,10 +2997,13 @@ CREATE TABLE workspace (workspace_id integer PRIMARY KEY AUTOINCREMENT,
g_return_val_if_fail (priv->db_connection != NULL, FALSE); g_return_val_if_fail (priv->db_connection != NULL, FALSE);
SDB_LOCK(priv);
if ((stmt = if ((stmt =
sdb_engine_get_statement_by_query_id (dbe, PREP_QUERY_WORKSPACE_NEW)) == NULL) sdb_engine_get_statement_by_query_id (dbe, PREP_QUERY_WORKSPACE_NEW)) == NULL)
{ {
g_warning ("query is null"); g_warning ("query is null");
SDB_UNLOCK(priv);
return FALSE; return FALSE;
} }
...@@ -3004,6 +3012,7 @@ CREATE TABLE workspace (workspace_id integer PRIMARY KEY AUTOINCREMENT, ...@@ -3004,6 +3012,7 @@ CREATE TABLE workspace (workspace_id integer PRIMARY KEY AUTOINCREMENT,
if ((param = gda_set_get_holder ((GdaSet*)plist, "wsname")) == NULL) if ((param = gda_set_get_holder ((GdaSet*)plist, "wsname")) == NULL)
{ {
g_warning ("param is NULL from pquery!\n"); g_warning ("param is NULL from pquery!\n");
SDB_UNLOCK(priv);
return FALSE; return FALSE;
} }
MP_SET_HOLDER_BATCH_STR(priv, param, workspace_name, ret_bool, ret_value); MP_SET_HOLDER_BATCH_STR(priv, param, workspace_name, ret_bool, ret_value);
...@@ -3013,12 +3022,15 @@ CREATE TABLE workspace (workspace_id integer PRIMARY KEY AUTOINCREMENT, ...@@ -3013,12 +3022,15 @@ CREATE TABLE workspace (workspace_id integer PRIMARY KEY AUTOINCREMENT,
(GdaStatement*)stmt, (GdaStatement*)stmt,
(GdaSet*)plist, NULL, NULL) == -1) (GdaSet*)plist, NULL, NULL) == -1)
{ {
SDB_UNLOCK(priv);
return FALSE; return FALSE;
} }
SDB_UNLOCK(priv);
return TRUE; return TRUE;
} }
/* ~~~ Thread note: this function locks the mutex ~~~ */
gboolean gboolean
symbol_db_engine_project_exists (SymbolDBEngine * dbe, /*gchar* workspace, */ symbol_db_engine_project_exists (SymbolDBEngine * dbe, /*gchar* workspace, */
const gchar * project_name) const gchar * project_name)
...@@ -3029,6 +3041,8 @@ symbol_db_engine_project_exists (SymbolDBEngine * dbe, /*gchar* workspace, */ ...@@ -3029,6 +3041,8 @@ symbol_db_engine_project_exists (SymbolDBEngine * dbe, /*gchar* workspace, */
priv = dbe->priv; priv = dbe->priv;
SDB_LOCK(priv);
g_return_val_if_fail (priv->db_connection != NULL, FALSE); g_return_val_if_fail (priv->db_connection != NULL, FALSE);
MP_LEND_OBJ_STR(priv,value); MP_LEND_OBJ_STR(priv,value);
g_value_set_static_string (value, project_name); g_value_set_static_string (value, project_name);
...@@ -3039,13 +3053,16 @@ symbol_db_engine_project_exists (SymbolDBEngine * dbe, /*gchar* workspace, */ ...@@ -3039,13 +3053,16 @@ symbol_db_engine_project_exists (SymbolDBEngine * dbe, /*gchar* workspace, */
"prjname", "prjname",
value)) <= 0) value)) <= 0)
{ {
SDB_UNLOCK(priv);
return FALSE; return FALSE;
} }
SDB_UNLOCK(priv);
/* we found it */ /* we found it */
return TRUE; return TRUE;
} }
/* ~~~ Thread note: this function locks the mutex ~~~ */
gboolean gboolean
symbol_db_engine_add_new_project (SymbolDBEngine * dbe, const gchar * workspace, symbol_db_engine_add_new_project (SymbolDBEngine * dbe, const gchar * workspace,
const gchar * project) const gchar * project)
...@@ -3070,6 +3087,8 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT, ...@@ -3070,6 +3087,8 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT,
g_return_val_if_fail (dbe != NULL, FALSE); g_return_val_if_fail (dbe != NULL, FALSE);
priv = dbe->priv; priv = dbe->priv;
SDB_LOCK(priv);
if (workspace == NULL) if (workspace == NULL)
{ {
GValue *value; GValue *value;
...@@ -3084,12 +3103,18 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT, ...@@ -3084,12 +3103,18 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT,
"wsname", "wsname",
value)) <= 0) value)) <= 0)
{ {
/* symbol_db_engine_add_new_workspace 'll lock so unlock here before */
SDB_UNLOCK(priv);
if (symbol_db_engine_add_new_workspace (dbe, workspace_name) == FALSE) if (symbol_db_engine_add_new_workspace (dbe, workspace_name) == FALSE)
{ {
DEBUG_PRINT ("%s", "Project cannot be added because a default workspace " DEBUG_PRINT ("%s", "Project cannot be added because a default workspace "
"cannot be created"); "cannot be created");
return FALSE; return FALSE;
} }
/* relock */
SDB_LOCK(priv);
} }
} }
else else
...@@ -3107,6 +3132,7 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT, ...@@ -3107,6 +3132,7 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT,
value)) <= 0) value)) <= 0)
{ {
DEBUG_PRINT ("No workspace id"); DEBUG_PRINT ("No workspace id");
SDB_UNLOCK(priv);
return FALSE; return FALSE;
} }
...@@ -3115,6 +3141,7 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT, ...@@ -3115,6 +3141,7 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT,
sdb_engine_get_statement_by_query_id (dbe, PREP_QUERY_PROJECT_NEW)) == NULL) sdb_engine_get_statement_by_query_id (dbe, PREP_QUERY_PROJECT_NEW)) == NULL)
{ {
g_warning ("query is null"); g_warning ("query is null");
SDB_UNLOCK(priv);
return FALSE; return FALSE;
} }
...@@ -3124,6 +3151,7 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT, ...@@ -3124,6 +3151,7 @@ CREATE TABLE project (project_id integer PRIMARY KEY AUTOINCREMENT,
if ((param = gda_set_get_holder ((GdaSet*)plist, "prjname")) == NULL) if ((param = gda_set_get_holder ((GdaSet*)plist, "prjname")) == NULL)
{ {
g_warning ("param prjname is NULL from pquery!");