[anjuta] am-project: bgo #570912 - Cannot remove module/package



commit b302b51b3469739c8e5facbe3896abe894cf3f65
Author: Sébastien Granjoux <seb sfo free fr>
Date:   Fri Mar 11 23:16:04 2011 +0100

    am-project: bgo #570912 - Cannot remove module/package

 libanjuta/anjuta-token-file.c         |    2 +-
 plugins/am-project/ac-writer.c        |   14 ++++++++------
 plugins/am-project/am-project.c       |    7 +++++++
 plugins/am-project/tests/Makefile.am  |    3 ++-
 plugins/am-project/tests/bugs.at      |   28 ++++++++++++++++++++++++++++
 plugins/am-project/tests/testsuite.at |    1 +
 6 files changed, 47 insertions(+), 8 deletions(-)
---
diff --git a/libanjuta/anjuta-token-file.c b/libanjuta/anjuta-token-file.c
index 3b3a1f6..cbc1f4f 100644
--- a/libanjuta/anjuta-token-file.c
+++ b/libanjuta/anjuta-token-file.c
@@ -264,7 +264,7 @@ anjuta_token_file_update (AnjutaTokenFile *file, AnjutaToken *token)
 	guint added;
 
 	/* Find all token needing an update */
-	
+
 	/* Find following tokens */
 	for (last = token; last != NULL; last = anjuta_token_next (last))
 	{
diff --git a/plugins/am-project/ac-writer.c b/plugins/am-project/ac-writer.c
index f3972ff..55c206e 100644
--- a/plugins/am-project/ac-writer.c
+++ b/plugins/am-project/ac-writer.c
@@ -338,17 +338,19 @@ amp_module_node_delete_token (AmpProject  *project, AmpModuleNode *module, GErro
 	token = amp_module_node_get_token (module);
 	if (token != NULL)
 	{
+		AnjutaToken *eol;
+		
 		token = anjuta_token_list (token);
 		anjuta_token_set_flags (token, ANJUTA_TOKEN_REMOVED);
-		token = anjuta_token_next_item (token);
-		if (anjuta_token_get_type (token) == ANJUTA_TOKEN_EOL)
+		eol = anjuta_token_next_item (token);
+		if (anjuta_token_get_type (eol) == ANJUTA_TOKEN_EOL)
 		{
-			anjuta_token_set_flags (token, ANJUTA_TOKEN_REMOVED);
+			anjuta_token_set_flags (eol, ANJUTA_TOKEN_REMOVED);
 		}
-		token = anjuta_token_next_item (token);
-		if (anjuta_token_get_type (token) == ANJUTA_TOKEN_EOL)
+		eol = anjuta_token_next_item (eol);
+		if (anjuta_token_get_type (eol) == ANJUTA_TOKEN_EOL)
 		{
-			anjuta_token_set_flags (token, ANJUTA_TOKEN_REMOVED);
+			anjuta_token_set_flags (eol, ANJUTA_TOKEN_REMOVED);
 		}
 
 		amp_project_update_configure (project, token);
diff --git a/plugins/am-project/am-project.c b/plugins/am-project/am-project.c
index 9c0f2b4..a9f1cff 100644
--- a/plugins/am-project/am-project.c
+++ b/plugins/am-project/am-project.c
@@ -1515,6 +1515,13 @@ amp_project_duplicate_node (AnjutaProjectNode *old_node)
 	{
 		amp_target_node_set_type (AMP_TARGET_NODE (new_node), anjuta_project_node_get_full_type (old_node));
 	}
+	if (anjuta_project_node_get_node_type (old_node) == ANJUTA_PROJECT_PACKAGE)
+	{
+		// FIXME: We should probably copy the version number too because it will not
+		// be updated when the node is reloaded. So later when updating the old_node,
+		// the value will be overwritten with the new node empty value.
+		amp_package_node_add_token (AMP_PACKAGE_NODE (new_node), amp_package_node_get_token (AMP_PACKAGE_NODE (old_node)));
+	}
 	/* Keep old parent, Needed for source node to find project root node */
 	new_node->parent = old_node->parent;
 
diff --git a/plugins/am-project/tests/Makefile.am b/plugins/am-project/tests/Makefile.am
index 53c338e..244229a 100644
--- a/plugins/am-project/tests/Makefile.am
+++ b/plugins/am-project/tests/Makefile.am
@@ -29,7 +29,8 @@ TESTSUITE_AT = \
 	$(srcdir)/module.at \
 	$(srcdir)/package.at \
 	$(srcdir)/target_module.at \
-	$(srcdir)/data_target.at
+	$(srcdir)/data_target.at \
+	$(srcdir)/bugs.at
 
 TESTSUITE = $(srcdir)/testsuite
 
diff --git a/plugins/am-project/tests/bugs.at b/plugins/am-project/tests/bugs.at
new file mode 100644
index 0000000..5ec41c7
--- /dev/null
+++ b/plugins/am-project/tests/bugs.at
@@ -0,0 +1,28 @@
+AT_SETUP([Various bugs])
+
+
+
+AS_MKDIR_P([project1])
+AT_DATA([project1/configure.ac],
+[[
+PKG_CHECK_MODULES(TEST,ncurses)
+AC_CONFIG_FILES(Makefile)
+]])
+AT_DATA([project1/Makefile.am],
+[[]])
+AT_DATA([expect],
+[[    GROUP (): bug1
+]])
+AT_PARSER_CHECK([load project1 \
+		 move bug1 \
+		 remove 0 \
+		 list \
+		 save])
+AT_CHECK([diff output expect])
+AT_PARSER_CHECK([load bug1 \
+		 list])
+AT_CHECK([diff output expect])
+
+
+
+AT_CLEANUP
diff --git a/plugins/am-project/tests/testsuite.at b/plugins/am-project/tests/testsuite.at
index f543f3f..4674ea5 100644
--- a/plugins/am-project/tests/testsuite.at
+++ b/plugins/am-project/tests/testsuite.at
@@ -12,3 +12,4 @@ m4_include([module.at])
 m4_include([package.at])
 m4_include([target_module.at])
 m4_include([data_target.at])
+m4_include([bugs.at])



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]