[anjuta/newproject] Fix loading of proxy nodes
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/newproject] Fix loading of proxy nodes
- Date: Fri, 7 May 2010 20:00:06 +0000 (UTC)
commit dc719fb88fd2e87a612e7b25294050d00196649a
Author: Sébastien Granjoux <seb sfo free fr>
Date: Thu May 6 22:34:17 2010 +0200
Fix loading of proxy nodes
libanjuta/anjuta-project.c | 83 +++++++++++++++++++++---------------
libanjuta/anjuta-project.h | 1 +
plugins/project-manager/plugin.c | 17 +-------
plugins/project-manager/project.c | 36 +++++++++++++---
4 files changed, 80 insertions(+), 57 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index b74a6b3..f64e876 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -780,48 +780,45 @@ anjuta_project_node_info_type (const AnjutaProjectNodeInfo *info)
AnjutaProjectNode *
anjuta_project_proxy_new (AnjutaProjectNode *node)
{
- if (NODE_DATA (node)->type & ANJUTA_PROJECT_PROXY)
+ AnjutaProjectProxyData *proxy;
+ AnjutaProjectNodeData *data;
+
+ /* If the node is already a proxy get original node */
+ node = anjuta_project_proxy_get_node (node);
+ data = NODE_DATA (node);
+
+ /* Create proxy node */
+ proxy = g_slice_new0(AnjutaProjectProxyData);
+ proxy->reference = 1;
+ proxy->node = node;
+ proxy->base.type = data->type | ANJUTA_PROJECT_PROXY;
+ proxy->base.file = data->file != NULL ? g_object_ref (data->file) : NULL;
+ proxy->base.name = g_strdup (data->name);
+
+ /* Shallow copy of all properties */
+ if ((data->properties == NULL) || (((AnjutaProjectPropertyInfo *)data->properties->data)->override == NULL))
{
- PROXY_DATA (node)->reference++;
+ proxy->base.properties = data->properties;
}
else
{
- AnjutaProjectProxyData *proxy;
- AnjutaProjectNodeData *data = NODE_DATA (node);
-
- /* Create proxy node */
- proxy = g_slice_new0(AnjutaProjectProxyData);
- proxy->reference = 1;
- proxy->node = node;
- proxy->base.type = data->type | ANJUTA_PROJECT_PROXY;
- proxy->base.file = data->file != NULL ? g_object_ref (data->file) : NULL;
- proxy->base.name = g_strdup (data->name);
-
- /* Shallow copy of all properties */
- if ((data->properties == NULL) || (((AnjutaProjectPropertyInfo *)data->properties->data)->override == NULL))
+ GList *item;
+ proxy->base.properties = g_list_copy (data->properties);
+ for (item = g_list_first (proxy->base.properties); item != NULL; item = g_list_next (item))
{
- proxy->base.properties = data->properties;
+ AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)item->data;
+ AnjutaProjectPropertyInfo *new_info;
+
+ new_info = g_slice_new0(AnjutaProjectPropertyInfo);
+ new_info->name = g_strdup (info->name);
+ new_info->type = info->type;
+ new_info->value = g_strdup (info->value);
+ new_info->override = info->override;
+ item->data = new_info;
}
- else
- {
- GList *item;
- proxy->base.properties = g_list_copy (data->properties);
- for (item = g_list_first (proxy->base.properties); item != NULL; item = g_list_next (item))
- {
- AnjutaProjectPropertyInfo *info = (AnjutaProjectPropertyInfo *)item->data;
- AnjutaProjectPropertyInfo *new_info;
-
- new_info = g_slice_new0(AnjutaProjectPropertyInfo);
- new_info->name = g_strdup (info->name);
- new_info->type = info->type;
- new_info->value = g_strdup (info->value);
- new_info->override = info->override;
- item->data = new_info;
- }
- }
-
- node = g_node_new (proxy);
}
+
+ node = g_node_new (proxy);
return node;
}
@@ -874,6 +871,21 @@ anjuta_project_proxy_exchange_data (AnjutaProjectNode *proxy, AnjutaProjectNode
return proxy;
}
+AnjutaProjectNode *
+anjuta_project_proxy_get_node (AnjutaProjectNode *node)
+{
+ g_return_val_if_fail (node != NULL, FALSE);
+
+ if (NODE_DATA (node)->type & ANJUTA_PROJECT_PROXY)
+ {
+ return (PROXY_DATA (node)->node);
+ }
+ else
+ {
+ return node;
+ }
+}
+
gboolean
anjuta_project_node_is_proxy (AnjutaProjectNode *node)
{
@@ -881,3 +893,4 @@ anjuta_project_node_is_proxy (AnjutaProjectNode *node)
return NODE_DATA (node)->type & ANJUTA_PROJECT_PROXY ? TRUE : FALSE;
}
+
diff --git a/libanjuta/anjuta-project.h b/libanjuta/anjuta-project.h
index 7f67f57..f86e3d1 100644
--- a/libanjuta/anjuta-project.h
+++ b/libanjuta/anjuta-project.h
@@ -209,6 +209,7 @@ AnjutaProjectNodeType anjuta_project_node_info_type (const AnjutaProjectNodeInfo
AnjutaProjectNode *anjuta_project_proxy_new (AnjutaProjectNode *node);
AnjutaProjectNode *anjuta_project_proxy_unref (AnjutaProjectNode *node);
AnjutaProjectNode *anjuta_project_proxy_exchange_data (AnjutaProjectNode *proxy, AnjutaProjectNode *node);
+AnjutaProjectNode *anjuta_project_proxy_get_node (AnjutaProjectNode *proxy);
gboolean anjuta_project_node_is_proxy (AnjutaProjectNode *node);
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index 7c5bdf6..68cc2ff 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -1223,22 +1223,7 @@ on_project_updated (AnjutaPmProject *project, GError *error, ProjectManagerPlugi
gchar *dirname;
dirname = anjuta_util_get_local_path_from_uri (plugin->project_root_uri);
- if (error)
- {
- GtkWidget *toplevel;
- GtkWindow *win;
-
- toplevel = gtk_widget_get_toplevel (plugin->scrolledwindow);
- if (toplevel && GTK_IS_WINDOW (toplevel))
- win = GTK_WINDOW (toplevel);
- else
- win = GTK_WINDOW (ANJUTA_PLUGIN (plugin)->shell);
-
- anjuta_util_dialog_error (win, _("Failed to parse project (the project is opened, but there will be no project view) %s: %s\n"
- ""),
- dirname, error->message);
- }
- else
+ if (!error)
{
/* Restore existing shortcut */
if (plugin->shortcuts != NULL)
diff --git a/plugins/project-manager/project.c b/plugins/project-manager/project.c
index 6ba12c3..b716aa5 100644
--- a/plugins/project-manager/project.c
+++ b/plugins/project-manager/project.c
@@ -201,11 +201,14 @@ pm_project_map_children (PmJob *job, AnjutaProjectNode *old_node, AnjutaProjectN
{
GList *children = NULL;
- for (new_node = anjuta_project_node_first_child (new_node); new_node != NULL; new_node = anjuta_project_node_next_sibling (new_node))
+ if (new_node != NULL)
{
- children = g_list_prepend (children, new_node);
+ for (new_node = anjuta_project_node_first_child (new_node); new_node != NULL; new_node = anjuta_project_node_next_sibling (new_node))
+ {
+ children = g_list_prepend (children, new_node);
+ }
+ children = g_list_reverse (children);
}
- children = g_list_reverse (children);
for (old_node = anjuta_project_node_first_child (old_node); old_node != NULL; old_node = anjuta_project_node_next_sibling (old_node))
{
@@ -220,6 +223,12 @@ pm_project_map_children (PmJob *job, AnjutaProjectNode *old_node, AnjutaProjectN
pm_project_map_children ((PmJob *)job, old_node, (AnjutaProjectNode *)same->data);
children = g_list_delete_link (children, same);
}
+ else
+ {
+ /* Mark deleted node */
+ g_hash_table_insert (job->map, old_node, NULL);
+ pm_project_map_children ((PmJob *)job, old_node, NULL);
+ }
}
g_list_free (children);
@@ -441,12 +450,27 @@ check_queue (GQueue *queue, GHashTable *map)
if (job->node != NULL)
{
AnjutaProjectNode *replace;
+ AnjutaProjectNode *node;
- replace = (AnjutaProjectNode *)g_hash_table_lookup (map, job->node);
- if (replace != NULL)
+ /* Get original node if we have a proxy here */
+ node = anjuta_project_proxy_get_node (job->node);
+
+ if (g_hash_table_lookup_extended (map, node, NULL, (gpointer *)&replace))
{
//g_message ("*** delete node %p used ***", job->node);
- job->node = replace;
+ if (replace != NULL)
+ {
+ /* Replaced node */
+ job->node = replace;
+ }
+ else
+ {
+ /* node has been deleted */
+ g_warning ("Node %s has been delete before executing command %d", anjuta_project_node_get_name (job->node), job->command);
+ job = g_queue_pop_nth (queue, i);
+ pm_job_free (job);
+ i--;
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]