[anjuta] am: bgo#635795 - Editing configure.ac crashes anjuta
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] am: bgo#635795 - Editing configure.ac crashes anjuta
- Date: Thu, 25 Nov 2010 21:20:11 +0000 (UTC)
commit 1bb675348edc4c7037c8d7a53914a92331b99077
Author: Sébastien Granjoux <seb sfo free fr>
Date: Thu Nov 25 22:06:28 2010 +0100
am: bgo#635795 - Editing configure.ac crashes anjuta
plugins/am-project/am-node.c | 32 ++++++++++----------
plugins/am-project/am-node.h | 2 +-
plugins/am-project/am-project-private.h | 1 -
plugins/am-project/am-project.c | 5 ++-
plugins/am-project/am-writer.c | 47 +++++++++++++++++-------------
5 files changed, 47 insertions(+), 40 deletions(-)
---
diff --git a/plugins/am-project/am-node.c b/plugins/am-project/am-node.c
index 0bbc02e..bd60e6b 100644
--- a/plugins/am-project/am-node.c
+++ b/plugins/am-project/am-node.c
@@ -427,7 +427,8 @@ on_group_monitor_changed (GFileMonitor *monitor,
GFileMonitorEvent event_type,
gpointer data)
{
- AnjutaAmGroupNode *node = ANJUTA_AM_GROUP_NODE (data);
+ AnjutaProjectNode *node = ANJUTA_PROJECT_NODE (data);
+ AnjutaProjectNode *root;
switch (event_type) {
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
@@ -435,7 +436,8 @@ on_group_monitor_changed (GFileMonitor *monitor,
case G_FILE_MONITOR_EVENT_DELETED:
/* project can be NULL, if the node is dummy node because the
* original one is reloaded. */
- if (node->project != NULL) g_signal_emit_by_name (G_OBJECT (node->project), "file-changed", data);
+ root = anjuta_project_node_root (node);
+ if (root != NULL) g_signal_emit_by_name (G_OBJECT (root), "file-changed", data);
break;
default:
break;
@@ -443,7 +445,7 @@ on_group_monitor_changed (GFileMonitor *monitor,
}
AnjutaTokenFile*
-amp_group_set_makefile (AnjutaAmGroupNode *group, GFile *makefile, GObject* project)
+amp_group_set_makefile (AnjutaAmGroupNode *group, GFile *makefile, AmpProject *project)
{
if (group->makefile != NULL) g_object_unref (group->makefile);
if (group->tfile != NULL) anjuta_token_file_free (group->tfile);
@@ -456,9 +458,9 @@ amp_group_set_makefile (AnjutaAmGroupNode *group, GFile *makefile, GObject* proj
group->tfile = anjuta_token_file_new (makefile);
token = anjuta_token_file_load (group->tfile, NULL);
- amp_project_add_file (AMP_PROJECT (project), makefile, group->tfile);
+ amp_project_add_file (project, makefile, group->tfile);
- scanner = amp_am_scanner_new (AMP_PROJECT (project), group);
+ scanner = amp_am_scanner_new (project, group);
group->make_token = amp_am_scanner_parse_token (scanner, anjuta_token_new_static (ANJUTA_TOKEN_FILE, NULL), token, makefile, NULL);
amp_am_scanner_free (scanner);
@@ -468,7 +470,6 @@ amp_group_set_makefile (AnjutaAmGroupNode *group, GFile *makefile, GObject* proj
NULL);
if (group->monitor != NULL)
{
- group->project = project;
g_signal_connect (G_OBJECT (group->monitor),
"changed",
G_CALLBACK (on_group_monitor_changed),
@@ -516,7 +517,8 @@ void
amp_group_update_node (AnjutaAmGroupNode *group, AnjutaAmGroupNode *new_group)
{
gint i;
-
+ GHashTable *hash;
+
if (group->monitor != NULL) g_object_unref (group->monitor);
if (group->makefile != NULL) g_object_unref (group->makefile);
if (group->tfile) anjuta_token_file_free (group->tfile);
@@ -524,7 +526,7 @@ amp_group_update_node (AnjutaAmGroupNode *group, AnjutaAmGroupNode *new_group)
{
if (group->tokens[i] != NULL) g_list_free (group->tokens[i]);
}
- if (group->variables) g_hash_table_destroy (group->variables);
+ if (group->variables) g_hash_table_remove_all (group->variables);
group->dist_only = new_group->dist_only;
group->makefile = new_group->makefile;
@@ -533,16 +535,16 @@ amp_group_update_node (AnjutaAmGroupNode *group, AnjutaAmGroupNode *new_group)
new_group->tfile = NULL;
memcpy (group->tokens, new_group->tokens, sizeof (group->tokens));
memset (new_group->tokens, 0, sizeof (new_group->tokens));
+ hash = group->variables;
group->variables = new_group->variables;
- new_group->variables = NULL;
- group->project = new_group->project;
+ new_group->variables = hash;
if (group->makefile != NULL)
{
group->monitor = g_file_monitor_file (group->makefile,
- G_FILE_MONITOR_NONE,
- NULL,
- NULL);
+ G_FILE_MONITOR_NONE,
+ NULL,
+ NULL);
if (group->monitor != NULL)
{
g_signal_connect (G_OBJECT (group->monitor),
@@ -551,7 +553,6 @@ amp_group_update_node (AnjutaAmGroupNode *group, AnjutaAmGroupNode *new_group)
group);
}
}
-
}
AnjutaAmGroupNode*
@@ -589,7 +590,6 @@ amp_group_new (GFile *file, gboolean dist_only, GError **error)
node = g_object_new (ANJUTA_TYPE_AM_GROUP_NODE, NULL);
node->base.file = g_object_ref (file);
node->dist_only = dist_only;
- node->variables = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify)amp_variable_free);
return node;
}
@@ -626,7 +626,7 @@ anjuta_am_group_node_init (AnjutaAmGroupNode *node)
node->dist_only = FALSE;
node->variables = NULL;
node->makefile = NULL;
- node->variables = NULL;
+ node->variables = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify)amp_variable_free);
node->monitor = NULL;
memset (node->tokens, 0, sizeof (node->tokens));
}
diff --git a/plugins/am-project/am-node.h b/plugins/am-project/am-node.h
index 2b5c664..ed138db 100644
--- a/plugins/am-project/am-node.h
+++ b/plugins/am-project/am-node.h
@@ -63,7 +63,7 @@ void amp_group_add_token (AnjutaAmGroupNode *group, AnjutaToken *token, AmpGroup
GList * amp_group_get_token (AnjutaAmGroupNode *group, AmpGroupTokenCategory category);
AnjutaToken* amp_group_get_first_token (AnjutaAmGroupNode *group, AmpGroupTokenCategory category);
void amp_group_set_dist_only (AnjutaAmGroupNode *group, gboolean dist_only);
-AnjutaTokenFile* amp_group_set_makefile (AnjutaAmGroupNode *group, GFile *makefile, GObject* project);
+AnjutaTokenFile* amp_group_set_makefile (AnjutaAmGroupNode *group, GFile *makefile, AmpProject *project);
AnjutaToken* amp_group_get_makefile_token (AnjutaAmGroupNode *group);
gchar *amp_group_get_makefile_name (AnjutaAmGroupNode *group);
gboolean amp_group_update_makefile (AnjutaAmGroupNode *group, AnjutaToken *token);
diff --git a/plugins/am-project/am-project-private.h b/plugins/am-project/am-project-private.h
index 7192788..e07d05e 100644
--- a/plugins/am-project/am-project-private.h
+++ b/plugins/am-project/am-project-private.h
@@ -125,7 +125,6 @@ struct _AnjutaAmGroupNode {
AnjutaToken *make_token;
GHashTable *variables;
GFileMonitor *monitor; /* File monitor */
- GObject *project; /* Project used by file monitor */
};
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index bb54d02..b073b6b 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -1563,7 +1563,7 @@ project_load_makefile (AmpProject *project, AnjutaAmGroupNode *group)
/* Parse makefile.am */
DEBUG_PRINT ("Parse: %s", g_file_get_uri (makefile));
- tfile = amp_group_set_makefile (group, makefile, G_OBJECT (project));
+ tfile = amp_group_set_makefile (group, makefile, project);
project_load_group_module (project, group);
@@ -2466,10 +2466,12 @@ amp_load_complete (PmJob *job)
GHashTable *map;
map = amp_project_map_node (job->node, job->proxy);
+ g_object_ref (job->proxy);
g_hash_table_foreach (map, (GHFunc)amp_project_update_node, map);
job->node->parent = job->parent;
job->proxy->parent = NULL;
g_hash_table_destroy (map);
+ g_object_unref (job->proxy);
job->proxy = NULL;
g_signal_emit_by_name (AMP_PROJECT (job->user_data), "node-loaded", job->node, job->error);
@@ -3023,7 +3025,6 @@ amp_project_dispose (GObject *object)
if (project->monitor) g_object_unref (project->monitor);
project->monitor = NULL;
-
G_OBJECT_CLASS (parent_class)->dispose (object);
}
diff --git a/plugins/am-project/am-writer.c b/plugins/am-project/am-writer.c
index b29689e..2e51ab7 100644
--- a/plugins/am-project/am-writer.c
+++ b/plugins/am-project/am-writer.c
@@ -413,7 +413,7 @@ amp_target_create_token (AmpProject *project, AnjutaAmTargetNode *target, GErro
gchar *targetname;
const gchar *name;
GList *last;
- AnjutaAmTargetNode *sibling;
+ AnjutaProjectNode *sibling;
AnjutaAmGroupNode *parent;
gboolean after;
@@ -424,21 +424,20 @@ amp_target_create_token (AmpProject *project, AnjutaAmTargetNode *target, GErro
name = anjuta_project_node_get_name (ANJUTA_PROJECT_NODE (target));
/* Find a sibling if possible */
- if (target->base.prev != NULL)
+ after = TRUE;
+ for (sibling = anjuta_project_node_prev_sibling (ANJUTA_PROJECT_NODE (target)); sibling != NULL; sibling = anjuta_project_node_prev_sibling (sibling))
{
- sibling = ANJUTA_AM_TARGET_NODE (target->base.prev);
- after = TRUE;
+ if (anjuta_project_node_get_node_type (sibling) == ANJUTA_PROJECT_TARGET) break;
}
- else if (target->base.next != NULL)
+ if (sibling == NULL)
{
- sibling = ANJUTA_AM_TARGET_NODE (target->base.next);
after = FALSE;
+ for (sibling = anjuta_project_node_next_sibling (ANJUTA_PROJECT_NODE (target)); sibling != NULL; sibling = anjuta_project_node_next_sibling (sibling))
+ {
+ if (anjuta_project_node_get_node_type (sibling) == ANJUTA_PROJECT_TARGET) break;
+ }
}
- else
- {
- sibling = NULL;
- after = TRUE;
- }
+ if (sibling == NULL) after = TRUE;
/* Add in Makefile.am */
targetname = g_strconcat (info->install, info->prefix, NULL);
@@ -449,7 +448,7 @@ amp_target_create_token (AmpProject *project, AnjutaAmTargetNode *target, GErro
prev = NULL;
if (sibling != NULL)
{
- last = amp_target_get_token (sibling, ANJUTA_TOKEN_ARGUMENT);
+ last = amp_target_get_token (ANJUTA_AM_TARGET_NODE (sibling), ANJUTA_TOKEN_ARGUMENT);
if (last != NULL)
{
@@ -634,6 +633,7 @@ amp_source_create_token (AmpProject *project, AnjutaAmSourceNode *source, GErro
{
AnjutaAmGroupNode *group;
AnjutaAmTargetNode *target;
+ AnjutaProjectNode *sibling;
gboolean after;
AnjutaToken *token;
AnjutaToken *prev;
@@ -649,23 +649,30 @@ amp_source_create_token (AmpProject *project, AnjutaAmSourceNode *source, GErro
/* Add in Makefile.am */
/* Find a sibling if possible */
- if (source->base.prev != NULL)
+ after = TRUE;
+ for (sibling = anjuta_project_node_prev_sibling (ANJUTA_PROJECT_NODE (source)); sibling != NULL; sibling = anjuta_project_node_prev_sibling (sibling))
{
- prev = ANJUTA_AM_SOURCE_NODE (source->base.prev)->token;
- after = TRUE;
- args = anjuta_token_list (prev);
+ if (anjuta_project_node_get_node_type (sibling) == ANJUTA_PROJECT_SOURCE) break;
}
- else if (source->base.next != NULL)
+ if (sibling == NULL)
{
- prev = ANJUTA_AM_SOURCE_NODE (source->base.next)->token;
after = FALSE;
- args = anjuta_token_list (prev);
+ for (sibling = anjuta_project_node_next_sibling (ANJUTA_PROJECT_NODE (source)); sibling != NULL; sibling = anjuta_project_node_next_sibling (sibling))
+ {
+ if (anjuta_project_node_get_node_type (sibling) == ANJUTA_PROJECT_SOURCE) break;
+ }
}
- else
+ if (sibling == NULL)
{
+ after = TRUE;
prev = NULL;
args = NULL;
}
+ else
+ {
+ prev = ANJUTA_AM_SOURCE_NODE (sibling)->token;
+ args = anjuta_token_list (prev);
+ }
/* Check if a valid source variable is already defined */
if (args == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]