Commit 7f33996f authored by Massimo Cora's avatar Massimo Cora

Don't let buffer-updating files which are not in current project.

	* plugins/symbol-db/plugin.c (do_add_new_files),
	(do_import_system_src_after_abort), (on_scan_end_manager):
	* plugins/symbol-db/symbol-db-engine-core.c
	(symbol_db_engine_update_project_symbols),
	(symbol_db_engine_update_buffer_symbols):
	Don't let buffer-updating files which are not in current project.

	* plugins/symbol-db/symbol-db-engine-core.h:
	* plugins/symbol-db/symbol-db-engine-iterator-node.c
	(symbol_db_engine_iterator_node_get_symbol_extra_string):
	* plugins/symbol-db/symbol-db-engine-iterator-node.h:
	* plugins/symbol-db/symbol-db-engine-iterator.h:
	* plugins/symbol-db/symbol-db-engine-priv.h:
	* plugins/symbol-db/symbol-db-engine.h:
	some minor headers fixes. 

svn path=/trunk/; revision=4480
parent 28e2ac07
2008-12-23 Massimo Cora' <mcora@svn.gnome.org>
* plugins/symbol-db/plugin.c (do_add_new_files),
(do_import_system_src_after_abort), (on_scan_end_manager):
* plugins/symbol-db/symbol-db-engine-core.c
(symbol_db_engine_update_project_symbols),
(symbol_db_engine_update_buffer_symbols):
Don't let buffer-updating files which are not in current project.
* plugins/symbol-db/symbol-db-engine-core.h:
* plugins/symbol-db/symbol-db-engine-iterator-node.c
(symbol_db_engine_iterator_node_get_symbol_extra_string):
* plugins/symbol-db/symbol-db-engine-iterator-node.h:
* plugins/symbol-db/symbol-db-engine-iterator.h:
* plugins/symbol-db/symbol-db-engine-priv.h:
* plugins/symbol-db/symbol-db-engine.h:
some minor headers fixes.
2008-12-23 Johannes Schmid <jhs@gnome.org>
* libanjuta/interfaces/libanjuta.idl:
......@@ -804,9 +804,6 @@ do_add_new_files (SymbolDBPlugin *sdb_plugin, const GPtrArray *sources_array,
continue;
}
DEBUG_PRINT ("wh0a, adding to scan local_filename %s (%s)", local_filename,
lang);
/* ok, we've just tested that the local_filename does exist.
* We can safely add it to the array.
*/
......@@ -1111,6 +1108,7 @@ do_import_system_src_after_abort (SymbolDBPlugin *sdb_plugin,
if (local_filename == NULL)
continue;
DEBUG_PRINT ("local_filename %s", local_filename);
gfile = g_file_new_for_path (local_filename);
if (gfile == NULL)
continue;
......@@ -1738,6 +1736,11 @@ on_scan_end_manager (SymbolDBEngine *dbe, gint process_id,
if (g_tree_remove (symbol_db->proc_id_tree, GINT_TO_POINTER (process_id)) == FALSE)
g_warning ("Cannot remove proc_id from GTree");
DEBUG_PRINT ("is_offline_scanning %d, is_project_importing %d, is_project_updating %d, "
"is_adding_element %d", symbol_db->is_offline_scanning,
symbol_db->is_project_importing, symbol_db->is_project_updating,
symbol_db->is_adding_element);
/**
* perform some checks on some booleans. If they're all successfully passed
* then activate the display of local view
......
......@@ -5409,7 +5409,6 @@ symbol_db_engine_update_project_symbols (SymbolDBEngine *dbe, const gchar *proje
if (!GDA_IS_DATA_MODEL (data_model) ||
(num_rows = gda_data_model_get_n_rows (GDA_DATA_MODEL (data_model))) <= 0)
{
DEBUG_PRINT ("no rows");
if (data_model != NULL)
g_object_unref (data_model);
data_model = NULL;
......@@ -5652,33 +5651,38 @@ symbol_db_engine_update_buffer_symbols (SymbolDBEngine * dbe, const gchar *proje
/* obtain a GPtrArray with real_files on database */
for (i=0; i < real_files_list->len; i++)
{
gchar *relative_path = symbol_db_engine_get_file_db_path (dbe,
g_ptr_array_index (real_files_list, i));
if (relative_path == NULL)
{
g_warning ("symbol_db_engine_update_buffer_symbols (): "
"relative_path is NULL");
return FALSE;
}
g_ptr_array_add (real_files_on_db, relative_path);
}
/* create a temporary file for each buffer */
for (i=0; i < real_files_list->len; i++)
{
gchar *relative_path;
const gchar *curr_abs_file;
FILE *buffer_mem_file;
const gchar *temp_buffer;
gint buffer_mem_fd;
gint temp_size;
gchar *shared_temp_file;
gchar *base_filename;
const gchar *curr_real_file;
curr_real_file = g_ptr_array_index (real_files_list, i);
curr_abs_file = g_ptr_array_index (real_files_list, i);
/* check if the file exists in db. We will not scan buffers for files
* which aren't already in db
*/
if (symbol_db_engine_file_exists (dbe, curr_abs_file) == FALSE)
{
DEBUG_PRINT ("will not scan buffer claiming to be %s because not in db",
curr_abs_file);
continue;
}
relative_path = symbol_db_engine_get_file_db_path (dbe, curr_abs_file);
if (relative_path == NULL)
{
g_warning ("symbol_db_engine_update_buffer_symbols (): "
"relative_path is NULL");
continue;
}
g_ptr_array_add (real_files_on_db, relative_path);
/* it's ok to have just the base filename to create the
* target buffer one */
base_filename = g_filename_display_basename (curr_real_file);
base_filename = g_filename_display_basename (relative_path);
shared_temp_file = g_strdup_printf ("/anjuta-%d-%ld-%s", getpid (),
time (NULL), base_filename);
......@@ -5689,7 +5693,7 @@ symbol_db_engine_update_buffer_symbols (SymbolDBEngine * dbe, const gchar *proje
{
g_warning ("Error while trying to open a shared memory file. Be"
"sure to have "SHARED_MEMORY_PREFIX" mounted with tmpfs");
return FALSE;
return -1;
}
buffer_mem_file = fdopen (buffer_mem_fd, "w+b");
......@@ -5721,18 +5725,25 @@ symbol_db_engine_update_buffer_symbols (SymbolDBEngine * dbe, const gchar *proje
g_free (shared_temp_file);
}
}
/* in case we didn't have any good buffer to scan...*/
ret_id = -1;
/* data will be freed when callback will be called. The signal will be
* disconnected too, don't worry about disconnecting it by hand.
*/
g_signal_connect (G_OBJECT (dbe), "scan-end",
G_CALLBACK (on_scan_update_buffer_end), real_files_list);
/* it may happens that no buffer is correctly set up */
if (real_files_on_db->len > 0)
{
/* data will be freed when callback will be called. The signal will be
* disconnected too, don't worry about disconnecting it by hand.
*/
g_signal_connect (G_OBJECT (dbe), "scan-end",
G_CALLBACK (on_scan_update_buffer_end), real_files_list);
ret_code = sdb_engine_scan_files_1 (dbe, temp_files, real_files_on_db, TRUE);
if (ret_code == TRUE)
ret_id = sdb_engine_get_unique_scan_id (dbe);
else
ret_id = -1;
ret_code = sdb_engine_scan_files_1 (dbe, temp_files, real_files_on_db, TRUE);
if (ret_code == TRUE)
ret_id = sdb_engine_get_unique_scan_id (dbe);
else
ret_id = -1;
}
/* let's free the temp_files array */
for (i=0; i < temp_files->len; i++)
......
......@@ -63,22 +63,8 @@ struct _SymbolDBEngine
SymbolDBEnginePriv *priv;
};
/* WARNING: these must match the ones on libanjuta.idl [AnjutaSymbol::Field] */
typedef enum {
SYMINFO_SIMPLE = 1,
SYMINFO_FILE_PATH = 2,
SYMINFO_IMPLEMENTATION = 4,
SYMINFO_ACCESS = 8,
SYMINFO_KIND = 16,
SYMINFO_TYPE = 32,
SYMINFO_TYPE_NAME = 64,
SYMINFO_LANGUAGE = 128,
SYMINFO_FILE_IGNORE = 256,
SYMINFO_FILE_INCLUDE = 512,
SYMINFO_PROJECT_NAME = 1024,
SYMINFO_WORKSPACE_NAME = 2048
} SymExtraInfo;
GType sdb_engine_get_type (void) G_GNUC_CONST;
......
......@@ -197,7 +197,7 @@ symbol_db_engine_iterator_node_get_symbol_signature (SymbolDBEngineIteratorNode
const gchar*
symbol_db_engine_iterator_node_get_symbol_extra_string (SymbolDBEngineIteratorNode *dbin,
gint sym_info)
SymExtraInfo sym_info)
{
SymbolDBEngineIteratorNodePriv *priv;
const GValue *value = NULL;
......
......@@ -28,6 +28,8 @@
#include <glib-object.h>
#include <libgda/libgda.h>
#include "symbol-db-engine-priv.h"
G_BEGIN_DECLS
#define SYMBOL_TYPE_DB_ENGINE_ITERATOR_NODE (sdb_engine_iterator_node_get_type ())
......@@ -76,7 +78,7 @@ symbol_db_engine_iterator_node_get_symbol_signature (SymbolDBEngineIteratorNode
*/
const gchar*
symbol_db_engine_iterator_node_get_symbol_extra_string (SymbolDBEngineIteratorNode *dbin,
gint sym_info);
SymExtraInfo sym_info);
void
symbol_db_engine_iterator_node_set_data (SymbolDBEngineIteratorNode *dbin,
......
......@@ -42,6 +42,8 @@ typedef struct _SymbolDBEngineIteratorClass SymbolDBEngineIteratorClass;
typedef struct _SymbolDBEngineIterator SymbolDBEngineIterator;
typedef struct _SymbolDBEngineIteratorPriv SymbolDBEngineIteratorPriv;
struct _SymbolDBEngineIteratorClass
{
SymbolDBEngineIteratorNodeClass parent_class;
......
......@@ -220,6 +220,24 @@ typedef struct _ChildDynQueryNode {
} DynChildQueryNode;
/* WARNING: these must match the ones on libanjuta.idl [AnjutaSymbol::Field] */
typedef enum {
SYMINFO_SIMPLE = 1,
SYMINFO_FILE_PATH = 2,
SYMINFO_IMPLEMENTATION = 4,
SYMINFO_ACCESS = 8,
SYMINFO_KIND = 16,
SYMINFO_TYPE = 32,
SYMINFO_TYPE_NAME = 64,
SYMINFO_LANGUAGE = 128,
SYMINFO_FILE_IGNORE = 256,
SYMINFO_FILE_INCLUDE = 512,
SYMINFO_PROJECT_NAME = 1024,
SYMINFO_WORKSPACE_NAME = 2048
} SymExtraInfo;
/* the SymbolDBEngine Private structure */
struct _SymbolDBEnginePriv
{
......
......@@ -99,7 +99,7 @@ symbol_db_engine_get_class_parents_by_symbol_id (SymbolDBEngine *dbe,
SymbolDBEngineIterator *
symbol_db_engine_get_current_scope (SymbolDBEngine *dbe,
const gchar* full_local_file_path, gulong line,
SymExtraInfo sym_info);
SymExtraInfo sym_info);
/**
......
......@@ -30,9 +30,12 @@
*/
#include "symbol-db-engine-core.h"
#include "symbol-db-engine-iterator-node.h"
#include "symbol-db-engine-iterator.h"
#include "symbol-db-engine-queries.h"
#include "symbol-db-engine-utils.h"
#include "symbol-db-engine-iterator.h"
#include "symbol-db-engine-iterator-node.h"
#endif
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