[anjuta] pm: Avoid a crash when deleting a target
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [anjuta] pm: Avoid a crash when deleting a target
- Date: Sat, 2 Jan 2010 15:06:32 +0000 (UTC)
commit 8b12b83c69fa9822c463f05ab7dad0a9a181ec1a
Author: Sébastien Granjoux <seb sfo free fr>
Date: Fri Jan 1 18:31:08 2010 +0100
pm: Avoid a crash when deleting a target
libanjuta/anjuta-project.c | 2 +-
plugins/project-manager/gbf-project-model.c | 20 ++++++++++++++------
2 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/libanjuta/anjuta-project.c b/libanjuta/anjuta-project.c
index 556fd4e..30c8b0d 100644
--- a/libanjuta/anjuta-project.c
+++ b/libanjuta/anjuta-project.c
@@ -153,7 +153,7 @@ anjuta_project_node_prepend (AnjutaProjectNode *parent, AnjutaProjectNode *node)
AnjutaProjectNodeType
anjuta_project_node_get_type (const AnjutaProjectNode *node)
{
- return NODE_DATA (node)->type;
+ return node == NULL ? ANJUTA_PROJECT_UNKNOWN : NODE_DATA (node)->type;
}
gchar *
diff --git a/plugins/project-manager/gbf-project-model.c b/plugins/project-manager/gbf-project-model.c
index 07183f1..1a12e27 100644
--- a/plugins/project-manager/gbf-project-model.c
+++ b/plugins/project-manager/gbf-project-model.c
@@ -599,6 +599,7 @@ update_group (GbfProjectModel *model, AnjutaProjectGroup *group, GtkTreeIter *it
{
GtkTreeModel *tree_model;
GtkTreeIter child;
+ GtkTreePath *shortcut;
GList *node;
GList *groups;
GList *targets;
@@ -627,7 +628,9 @@ update_group (GbfProjectModel *model, AnjutaProjectGroup *group, GtkTreeIter *it
/* find the iterating id in the group's children */
data = gbf_project_model_get_node (model, &child);
- if (anjuta_project_node_get_type (data) == ANJUTA_PROJECT_GROUP) {
+ switch (anjuta_project_node_get_type (data))
+ {
+ case ANJUTA_PROJECT_GROUP:
/* update recursively */
update_group (model, data, &child);
if (group && (node = g_list_find (groups, data))) {
@@ -635,10 +638,8 @@ update_group (GbfProjectModel *model, AnjutaProjectGroup *group, GtkTreeIter *it
} else {
remove_child = TRUE;
}
-
- } else if (anjuta_project_node_get_type (data) == ANJUTA_PROJECT_TARGET) {
- GtkTreePath *shortcut;
-
+ break;
+ case ANJUTA_PROJECT_TARGET:
if (group && (node = g_list_find (targets, data))) {
targets = g_list_delete_link (targets, node);
/* update recursively */
@@ -663,12 +664,19 @@ update_group (GbfProjectModel *model, AnjutaProjectGroup *group, GtkTreeIter *it
}
gtk_tree_path_free (shortcut);
}
- } else if (anjuta_project_node_get_type (data) == ANJUTA_PROJECT_SOURCE) {
+ break;
+ case ANJUTA_PROJECT_SOURCE:
if ((data) && (node = g_list_find (sources, data))) {
sources = g_list_delete_link (sources, node);
} else {
remove_child = TRUE;
}
+ break;
+ case ANJUTA_PROJECT_UNKNOWN:
+ remove_child = TRUE;
+ break;
+ default:
+ g_return_if_reached ();
}
if (remove_child)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]