[anjuta] build-basic-autotools: bgo# 590323 - Make the context menu "context"-aware



commit 4c2d0df50719f0356d3ed076a8d4b5cc5d881979
Author: SÃbastien Granjoux <seb sfo free fr>
Date:   Thu Jun 30 21:29:05 2011 +0200

    build-basic-autotools: bgo# 590323 - Make the context menu "context"-aware

 plugins/build-basic-autotools/build.c  |  162 ++++++++++++-----------
 plugins/build-basic-autotools/build.h  |    1 +
 plugins/build-basic-autotools/plugin.c |  226 +++++++++++++++++++++++---------
 plugins/project-manager/plugin.c       |    6 +-
 4 files changed, 253 insertions(+), 142 deletions(-)
---
diff --git a/plugins/build-basic-autotools/build.c b/plugins/build-basic-autotools/build.c
index 9cc6e82..87dc936 100644
--- a/plugins/build-basic-autotools/build.c
+++ b/plugins/build-basic-autotools/build.c
@@ -281,6 +281,81 @@ build_file_from_file (BasicAutotoolsPlugin *plugin, GFile *file, gchar **target)
 	}
 }
 
+GFile *
+build_object_from_file (BasicAutotoolsPlugin *plugin, GFile *file)
+{
+	GFile *object = NULL;
+	IAnjutaProjectManager* projman;
+
+	/* Check that the GFile is a regular file */
+	if ((file == NULL) || (g_file_query_file_type (file, 0, NULL) == G_FILE_TYPE_DIRECTORY))
+	{
+		return NULL;
+	}
+	
+	projman = anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin)->shell,
+				                            IAnjutaProjectManager,
+				                            NULL);
+	if ((projman != NULL) && ianjuta_project_manager_is_open (projman, NULL))
+	{
+		/* Use the project manager to find the object file */		
+		object = ianjuta_project_manager_get_parent (projman, file, NULL);
+		if (object != NULL)
+		{
+			if (ianjuta_project_manager_get_target_type (projman, object, NULL) != ANJUTA_PROJECT_OBJECT)
+			{
+				g_object_unref (object);
+				object = NULL;
+			}
+		}
+	}
+	else
+	{
+		/* Use language plugin trying to find an object file */	
+		IAnjutaLanguage* langman =	anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin)->shell,
+			                                                      IAnjutaLanguage,
+			                                                      NULL);
+
+		if (langman != NULL)
+		{
+			GFileInfo* file_info;
+
+			file_info = g_file_query_info (file,
+				                                          G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+				                                          G_FILE_QUERY_INFO_NONE,
+		    		                                      NULL,
+		        		                                  NULL);
+			if (file_info)
+			{
+				gint id = ianjuta_language_get_from_mime_type (langman,
+			    	                                           g_file_info_get_content_type (file_info),
+			        	                                       NULL);
+				if (id > 0)
+				{
+					const gchar *obj_ext = ianjuta_language_get_make_target (langman, id, NULL);
+					gchar *basename;
+					gchar *ext;
+					gchar *targetname;
+					GFile *parent;
+
+					basename = g_file_get_basename (file);
+					ext = strrchr (basename, '.');
+					if ((ext != NULL) && (ext != basename)) *ext = '\0';
+					targetname = g_strconcat (basename, obj_ext, NULL);
+					g_free (basename);
+					parent = g_file_get_parent (file);
+					object = g_file_get_child (parent, targetname);
+					g_object_unref (parent);
+					g_free (targetname);
+				}
+			}
+			g_object_unref (file_info);
+		}
+	}
+
+	return object;
+}
+
 /* Save & Build
  *---------------------------------------------------------------------------*/
 
@@ -598,94 +673,29 @@ BuildContext*
 build_compile_file (BasicAutotoolsPlugin *plugin, GFile *file)
 {
 	BuildContext *context = NULL;
-	GFile *target = NULL;
-	gboolean ret;
-	IAnjutaProjectManager* projman;
+	BuildProgram *prog;
+	GFile *object;
+	gchar *target_name;
 	
 	g_return_val_if_fail (file != NULL, FALSE);
-	ret = FALSE;
-	
-	projman = anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin)->shell,
-				                            IAnjutaProjectManager,
-				                            NULL);
-	if ((projman != NULL) && ianjuta_project_manager_is_open (projman, NULL))
-	{
-		/* Use the project manager to find the object file */		
-		target = ianjuta_project_manager_get_parent (projman, file, NULL);
-		if (target != NULL)
-		{
-			if (ianjuta_project_manager_get_target_type (projman, target, NULL) != ANJUTA_PROJECT_OBJECT)
-			{
-				g_object_unref (target);
-				target = NULL;
-			}
-		}
-	}
-	else
-	{
-		/* Use language plugin trying to find an object file */	
-		IAnjutaLanguage* langman =	anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin)->shell,
-			                                                      IAnjutaLanguage,
-			                                                      NULL);
-
-		if (langman != NULL)
-		{
-			GFileInfo* file_info;
-
-			file_info = g_file_query_info (file,
-				                                          G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
-				                                          G_FILE_QUERY_INFO_NONE,
-		    		                                      NULL,
-		        		                                  NULL);
-			if (file_info)
-			{
-				gint id = ianjuta_language_get_from_mime_type (langman,
-			    	                                           g_file_info_get_content_type (file_info),
-			        	                                       NULL);
-				if (id > 0)
-				{
-					const gchar *obj_ext = ianjuta_language_get_make_target (langman, id, NULL);
-					gchar *basename;
-					gchar *ext;
-					gchar *targetname;
-					GFile *parent;
 
-					basename = g_file_get_basename (file);
-					ext = strrchr (basename, '.');
-					if ((ext != NULL) && (ext != basename)) *ext = '\0';
-					targetname = g_strconcat (basename, obj_ext, NULL);
-					g_free (basename);
-					parent = g_file_get_parent (file);
-					target = g_file_get_child (parent, targetname);
-					g_object_unref (parent);
-					g_free (targetname);
-				}
-			}
-			g_object_unref (file_info);
-		}
-	}
-		
-	if (target != NULL)
+	object = build_object_from_file (plugin, file);
+	if (object != NULL)
 	{
-		/* If file has no extension, take it as target itself */
-		BuildProgram *prog;
 		GFile *build_dir;
-		gchar *target_name;
-
+		
 		/* Find target directory */
-		build_dir = build_file_from_file (plugin, target, &target_name);
+		build_dir = build_file_from_file (plugin, object, &target_name);
 
 		prog = build_program_new_with_command (build_dir, "%s %s",
-		                                       CHOOSE_COMMAND(plugin, COMPILE),
-		                                       (target_name == NULL) ? "" : target_name);
+	    	                                   CHOOSE_COMMAND(plugin, COMPILE),
+	        	                               (target_name == NULL) ? "" : target_name);
 		g_free (target_name);
 		g_object_unref (build_dir);
 		context = build_save_and_execute_command (plugin, prog, TRUE, NULL);
-		ret = TRUE;
-		g_object_unref (target);
+		g_object_unref (object);
 	}
-	
-	if (ret == FALSE)
+	else
 	{
 		/* FIXME: Prompt the user to create a Makefile with a wizard
 		   (if there is no Makefile in the directory) or to add a target
diff --git a/plugins/build-basic-autotools/build.h b/plugins/build-basic-autotools/build.h
index 94cd385..be86c66 100644
--- a/plugins/build-basic-autotools/build.h
+++ b/plugins/build-basic-autotools/build.h
@@ -30,6 +30,7 @@
 
 
 GFile * build_file_from_file (BasicAutotoolsPlugin *plugin, GFile *file, gchar **target);
+GFile * build_object_from_file (BasicAutotoolsPlugin *plugin, GFile *file);
 gboolean directory_has_makefile (GFile *dir);
 gboolean directory_has_makefile_am (BasicAutotoolsPlugin *bb_plugin,  GFile *dir);
 
diff --git a/plugins/build-basic-autotools/plugin.c b/plugins/build-basic-autotools/plugin.c
index 7599033..6bd2424 100644
--- a/plugins/build-basic-autotools/plugin.c
+++ b/plugins/build-basic-autotools/plugin.c
@@ -1374,16 +1374,19 @@ build_module_from_file (BasicAutotoolsPlugin *plugin, GFile *file, gchar **targe
 		/* No project, use file without extension */
 		gchar *basename;
 		GFile *module = NULL;
+		GFile *parent;
 		gchar *ptr;
 
 		basename = g_file_get_basename (file);
 		ptr = strrchr (basename, '.');
 		if ((ptr != NULL) && (ptr != basename))
 		{
-			GFile *parent;
 			
 			*ptr = '\0';
-			parent = g_file_get_parent (file);
+		}
+		parent = g_file_get_parent (file);
+		if (parent != NULL)
+		{
 			module = g_file_get_child (parent, basename);
 			g_object_unref (parent);
 		}
@@ -1454,8 +1457,11 @@ on_build_module (GtkAction *action, BasicAutotoolsPlugin *plugin)
 	g_return_if_fail (plugin->current_editor_file != NULL);
 
 	module = build_module_from_file (plugin, plugin->current_editor_file, NULL);
-	build_configure_and_build (plugin, build_build_file_or_dir, module);
-	g_object_unref (module);
+	if (module != NULL)
+	{
+		build_configure_and_build (plugin, build_build_file_or_dir, module);
+		g_object_unref (module);
+	}
 }
 
 static void
@@ -1529,8 +1535,11 @@ fm_build (GtkAction *action, BasicAutotoolsPlugin *plugin)
 	g_return_if_fail (plugin->fm_current_file != NULL);
 
 	module = build_module_from_file (plugin, plugin->fm_current_file, NULL);
-	build_configure_and_build (plugin, build_build_file_or_dir, module);
-	g_object_unref (module);
+	if (module != NULL)
+	{
+		build_configure_and_build (plugin, build_build_file_or_dir, module);
+		g_object_unref (module);
+	}
 }
 
 static void
@@ -1566,8 +1575,11 @@ pm_build (GtkAction *action, BasicAutotoolsPlugin *plugin)
 	g_return_if_fail (plugin->pm_current_file != NULL);
 
 	module = build_module_from_file (plugin, plugin->pm_current_file, NULL);
-	build_configure_and_build (plugin, build_build_file_or_dir, module);
-	g_object_unref (module);
+	if (module != NULL)
+	{
+		build_configure_and_build (plugin, build_build_file_or_dir, module);
+		g_object_unref (module);
+	}
 }
 
 static void
@@ -1771,6 +1783,7 @@ update_module_ui (BasicAutotoolsPlugin *bb_plugin)
 	gboolean has_file = FALSE;
 	gboolean has_makefile= FALSE;
 	gboolean has_project = TRUE;
+	gboolean has_object = FALSE;
 
 	ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (bb_plugin)->shell, NULL);
 	
@@ -1793,6 +1806,10 @@ update_module_ui (BasicAutotoolsPlugin *bb_plugin)
 		g_free (target);
 		has_makefile = directory_has_makefile (mod) || directory_has_makefile_am (bb_plugin, mod);
 		g_object_unref (mod);
+
+		mod = build_object_from_file (bb_plugin, bb_plugin->current_editor_file);
+		has_object = mod != NULL;
+		g_object_unref (mod);
 	}
 	has_project = bb_plugin->project_root_dir != NULL;
 
@@ -1821,7 +1838,7 @@ update_module_ui (BasicAutotoolsPlugin *bb_plugin)
 	action = anjuta_ui_get_action (ui, "ActionGroupBuild",
 								   "ActionBuildCompileFile");
 	label = g_strdup_printf (filename ? _("Co_mpile (%s)") : _("Co_mpile"), filename);
-	g_object_set (G_OBJECT (action), "sensitive", has_file,
+	g_object_set (G_OBJECT (action), "sensitive", has_object,
 					  "label", label, NULL);
 	g_free (label);
 	
@@ -1830,6 +1847,125 @@ update_module_ui (BasicAutotoolsPlugin *bb_plugin)
 }
 
 static void
+update_fm_module_ui (BasicAutotoolsPlugin *bb_plugin)
+{
+	AnjutaUI *ui;
+	GtkAction *action;
+	gboolean has_file = FALSE;
+	gboolean has_makefile= FALSE;
+	gboolean has_project = TRUE;
+	gboolean has_object = FALSE;
+	gboolean is_directory = FALSE;
+
+	ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (bb_plugin)->shell, NULL);
+	
+	has_file = bb_plugin->fm_current_file != NULL;
+	if (has_file)
+	{
+		GFile *mod;
+
+		mod = build_module_from_file (bb_plugin, bb_plugin->fm_current_file, NULL);
+		if (mod != NULL)
+		{
+			has_makefile = directory_has_makefile (mod) || directory_has_makefile_am (bb_plugin, mod);
+			g_object_unref (mod);
+		}
+
+		is_directory = g_file_query_file_type (bb_plugin->fm_current_file, 0, NULL) == G_FILE_TYPE_DIRECTORY;
+		if (!is_directory)
+		{
+			mod = build_object_from_file (bb_plugin, bb_plugin->fm_current_file);
+			if (mod != NULL)
+			{
+				has_object = TRUE;
+				g_object_unref (mod);
+			}
+		}
+	}
+	has_project = bb_plugin->project_root_dir != NULL;
+
+	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild",
+									   "ActionPopupBuild");
+	g_object_set (G_OBJECT (action), "visible", has_file && (has_makefile || (!is_directory && !has_project)), NULL);
+
+	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild",
+								   "ActionPopupBuildCompile");
+	g_object_set (G_OBJECT (action), "sensitive", has_object, "visible", !is_directory, NULL);
+	
+	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild",
+								   "ActionPopupBuildBuild");
+	g_object_set (G_OBJECT (action), "sensitive", has_file && (has_makefile || (!is_directory && !has_project)), NULL);
+
+	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild",
+								   "ActionPopupBuildInstall");
+	g_object_set (G_OBJECT (action), "sensitive", has_makefile, "visible", has_project, NULL);
+
+	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild",
+								   "ActionPopupBuildClean");
+	g_object_set (G_OBJECT (action), "sensitive", has_makefile, "visible", has_project, NULL);
+}
+
+static void
+update_pm_module_ui (BasicAutotoolsPlugin *bb_plugin)
+{
+	AnjutaUI *ui;
+	GtkAction *action;
+	gboolean has_file = FALSE;
+	gboolean has_makefile= FALSE;
+	gboolean has_project = TRUE;
+	gboolean has_object = FALSE;
+	gboolean is_directory = FALSE;
+
+	ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (bb_plugin)->shell, NULL);
+	
+	has_file = bb_plugin->pm_current_file != NULL;
+	if (has_file)
+	{
+		GFile *mod;
+
+		mod = build_module_from_file (bb_plugin, bb_plugin->pm_current_file, NULL);
+		if (mod != NULL)
+		{
+			has_makefile = directory_has_makefile (mod) || directory_has_makefile_am (bb_plugin, mod);
+			g_object_unref (mod);
+		}
+
+		is_directory = g_file_query_file_type (bb_plugin->pm_current_file, 0, NULL) == G_FILE_TYPE_DIRECTORY;
+		if (!is_directory)
+		{
+			mod = build_object_from_file (bb_plugin, bb_plugin->pm_current_file);
+			if (mod != NULL)
+			{
+				has_object = TRUE;
+				g_object_unref (mod);
+			}
+		}
+	}
+	has_project = bb_plugin->project_root_dir != NULL;
+
+	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild",
+									   "ActionPopupPMBuild");
+	g_object_set (G_OBJECT (action), "visible", has_file && (has_makefile || !has_project), NULL);
+	
+	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild",
+								   "ActionPopupPMBuildCompile");
+	g_object_set (G_OBJECT (action), "sensitive", has_object, "visible", !is_directory, NULL);
+	
+	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild",
+								   "ActionPopupPMBuildBuild");
+	g_object_set (G_OBJECT (action), "sensitive", has_file && (has_makefile || !has_project), NULL);
+
+	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild",
+								   "ActionPopupPMBuildInstall");
+	g_object_set (G_OBJECT (action), "sensitive", has_makefile, "visible", has_project, NULL);
+
+	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild",
+								   "ActionPopupPMBuildClean");
+	g_object_set (G_OBJECT (action), "sensitive", has_makefile, "visible", has_project, NULL);
+}
+
+
+static void
 update_project_ui (BasicAutotoolsPlugin *bb_plugin)
 {
 	AnjutaUI *ui;
@@ -1845,25 +1981,25 @@ update_project_ui (BasicAutotoolsPlugin *bb_plugin)
 	ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (bb_plugin)->shell, NULL);
 	action = anjuta_ui_get_action (ui, "ActionGroupBuild",
 								   "ActionBuildBuildProject");
-	g_object_set (G_OBJECT (action), "sensitive", has_project, NULL);
+	g_object_set (G_OBJECT (action), "sensitive", has_project, "visible", has_project, NULL);
 	action = anjuta_ui_get_action (ui, "ActionGroupBuild",
 								   "ActionBuildInstallProject");
-	g_object_set (G_OBJECT (action), "sensitive", has_project, NULL);
+	g_object_set (G_OBJECT (action), "sensitive", has_project, "visible", has_project, NULL);
 	action = anjuta_ui_get_action (ui, "ActionGroupBuild",
 								   "ActionBuildCleanProject");
-	g_object_set (G_OBJECT (action), "sensitive", has_makefile, NULL);
+	g_object_set (G_OBJECT (action), "sensitive", has_makefile, "visible", has_project, NULL);
 	action = anjuta_ui_get_action (ui, "ActionGroupBuild",
 								   "ActionBuildDistribution");
-	g_object_set (G_OBJECT (action), "sensitive", has_project, NULL);
+	g_object_set (G_OBJECT (action), "sensitive", has_project, "visible", has_project, NULL);
 	action = anjuta_ui_get_action (ui, "ActionGroupBuild",
 								   "ActionBuildConfigure");
-	g_object_set (G_OBJECT (action), "sensitive", has_project, NULL);
+	g_object_set (G_OBJECT (action), "sensitive", has_project, "visible", has_project, NULL);
 	action = anjuta_ui_get_action (ui, "ActionGroupBuild",
 								   "ActionBuildSelectConfiguration");
-	g_object_set (G_OBJECT (action), "sensitive", has_project, NULL);
+	g_object_set (G_OBJECT (action), "sensitive", has_project, "visible", has_project, NULL);
 	action = anjuta_ui_get_action (ui, "ActionGroupBuild",
 								   "ActionBuildRemoveConfiguration");
-	g_object_set (G_OBJECT (action), "sensitive", has_makefile, NULL);
+	g_object_set (G_OBJECT (action), "sensitive", has_makefile, "visible", has_project, NULL);
 	
 	update_module_ui (bb_plugin);
 }
@@ -1973,94 +2109,54 @@ static void
 value_added_fm_current_file (AnjutaPlugin *plugin, const char *name,
 							const GValue *value, gpointer data)
 {
-	AnjutaUI *ui;
-	GtkAction *action;
-	GFile* file;
-	GFile *build_dir;
-	gboolean makefile_exists;
-	
-	file = g_value_get_object (value);
-
 	BasicAutotoolsPlugin *ba_plugin = ANJUTA_PLUGIN_BASIC_AUTOTOOLS (plugin);
-	ui = anjuta_shell_get_ui (plugin->shell, NULL);
 	
 	if (ba_plugin->fm_current_file)
 		g_object_unref (ba_plugin->fm_current_file);
-	ba_plugin->fm_current_file = file;
-	
-	build_dir = build_file_from_file (ba_plugin, file, NULL);
-	makefile_exists = directory_has_makefile (build_dir) || directory_has_makefile_am (ba_plugin, build_dir);
-	g_object_unref (build_dir);
-	
-	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild", "ActionPopupBuild");
-	g_object_set (G_OBJECT (action), "sensitive", TRUE, NULL);
-	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild",
-										"ActionPopupBuildCompile");
-	g_object_set (G_OBJECT (action), "sensitive", makefile_exists, NULL);
+	ba_plugin->fm_current_file = g_value_get_object (value);
+
+	update_fm_module_ui (ba_plugin);
 }
 
 static void
 value_removed_fm_current_file (AnjutaPlugin *plugin,
 							  const char *name, gpointer data)
 {
-	AnjutaUI *ui;
-	GtkAction *action;
 	BasicAutotoolsPlugin *ba_plugin = ANJUTA_PLUGIN_BASIC_AUTOTOOLS (plugin);
 	
 	if (ba_plugin->fm_current_file)
 		g_object_unref (ba_plugin->fm_current_file);
 	ba_plugin->fm_current_file = NULL;
-	
-	ui = anjuta_shell_get_ui (plugin->shell, NULL);
-	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild", "ActionPopupBuild");
-	g_object_set (G_OBJECT (action), "sensitive", FALSE, NULL);
+
+	update_fm_module_ui (ba_plugin);
 }
 
 static void
 value_added_pm_current_uri (AnjutaPlugin *plugin, const char *name,
 							const GValue *value, gpointer data)
 {
-	AnjutaUI *ui;
-	GtkAction *action;
+	BasicAutotoolsPlugin *ba_plugin = ANJUTA_PLUGIN_BASIC_AUTOTOOLS (plugin);
 	const gchar *uri;
-	GFile *build_dir;
-	gboolean makefile_exists;
 	
 	uri = g_value_get_string (value);
-	
-	BasicAutotoolsPlugin *ba_plugin = ANJUTA_PLUGIN_BASIC_AUTOTOOLS (plugin);
-	ui = anjuta_shell_get_ui (plugin->shell, NULL);
-	
 	if (ba_plugin->pm_current_file)
 		g_object_unref (ba_plugin->pm_current_file);
 	ba_plugin->pm_current_file = g_file_new_for_uri (uri);
 
-	build_dir = build_file_from_file (ba_plugin, ba_plugin->pm_current_file, NULL);
-	makefile_exists = directory_has_makefile (build_dir) || directory_has_makefile_am (ba_plugin, build_dir);
-	g_object_unref (build_dir);
-	
-	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild", "ActionPopupPMBuild");
-	g_object_set (G_OBJECT (action), "sensitive", TRUE, NULL);
-	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild",
-										"ActionPopupPMBuildCompile");
-	g_object_set (G_OBJECT (action), "sensitive", makefile_exists, NULL);
+	update_pm_module_ui (ba_plugin);
 }
 
 static void
 value_removed_pm_current_uri (AnjutaPlugin *plugin,
 							  const char *name, gpointer data)
 {
-	AnjutaUI *ui;
-	GtkAction *action;
 	BasicAutotoolsPlugin *ba_plugin = ANJUTA_PLUGIN_BASIC_AUTOTOOLS (plugin);
 	
 	if (ba_plugin->pm_current_file)
 		g_object_unref (ba_plugin->pm_current_file);
 	ba_plugin->pm_current_file = NULL;
-	
-	ui = anjuta_shell_get_ui (plugin->shell, NULL);
-	action = anjuta_ui_get_action (ui, "ActionGroupPopupBuild", "ActionPopupPMBuild");
-	g_object_set (G_OBJECT (action), "sensitive", FALSE, NULL);
+
+	update_pm_module_ui (ba_plugin);
 }
 
 static void
diff --git a/plugins/project-manager/plugin.c b/plugins/project-manager/plugin.c
index 76b8cf1..5679372 100644
--- a/plugins/project-manager/plugin.c
+++ b/plugins/project-manager/plugin.c
@@ -1991,7 +1991,11 @@ iproject_manager_get_parent (IAnjutaProjectManager *project_manager,
 		{
 			node = get_node_from_file (node, element);
 			if (node != NULL) node = anjuta_project_node_parent (node);
-			if (node != NULL) file = g_object_ref (anjuta_project_node_get_file (node));
+			if (node != NULL)
+			{
+				file = anjuta_project_node_get_file (node);
+				if (file != NULL) g_object_ref (file);
+			}
 		}
 	}
 



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