[anjuta] build-basic-autotools: Add proper error handling for IAnjutaEnvironment



commit 4e0ebc9b6ca3e3ae56cb0be326c4623123f7944b
Author: Johannes Schmid <jhs gnome org>
Date:   Fri Nov 26 16:41:07 2010 +0100

    build-basic-autotools: Add proper error handling for IAnjutaEnvironment

 configure.ac                            |    1 +
 libanjuta/interfaces/libanjuta.idl      |   14 +++++++++++++-
 plugins/build-basic-autotools/plugin.c  |    6 +++++-
 plugins/build-basic-autotools/program.c |   22 +++++++++++++++++++---
 plugins/build-basic-autotools/program.h |    2 +-
 5 files changed, 39 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 26f9bd3..e48b72c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -824,6 +824,7 @@ launcher/Makefile
 plugins/Makefile
 plugins/class-gen/Makefile
 plugins/class-gen/templates/Makefile
+plugins/code-analyzer/Makefile
 plugins/patch/Makefile
 plugins/document-manager/Makefile
 plugins/document-manager/images/Makefile
diff --git a/libanjuta/interfaces/libanjuta.idl b/libanjuta/interfaces/libanjuta.idl
index cbd72b5..8a50327 100644
--- a/libanjuta/interfaces/libanjuta.idl
+++ b/libanjuta/interfaces/libanjuta.idl
@@ -1,4 +1,3 @@
-
 // -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
 // -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
 //
@@ -783,6 +782,19 @@ interface IAnjutaBuilder
 interface IAnjutaEnvironment
 {
 	/**
+   * IAnjutaEnvironmentError:
+   * @IANJUTA_BUILDER_CONFIG: Configuration of the environment is wrong
+   * @IANJUTA_BUILDER_OTHER_ERROR: Other Error (no unknown ;-))   
+   *
+   * Possible build errors
+   */	 
+	enum Error
+	{
+		CONFIG,
+		OTHER_ERROR
+	}
+
+	/**
 	* ianjuta_environment_override:
 	* @obj: Self
 	* @dirp: a pointer on the working directory
diff --git a/plugins/build-basic-autotools/plugin.c b/plugins/build-basic-autotools/plugin.c
index a9253f5..f4273e3 100644
--- a/plugins/build-basic-autotools/plugin.c
+++ b/plugins/build-basic-autotools/plugin.c
@@ -1373,7 +1373,11 @@ build_execute_command_in_context (BuildContext* context, GError **err)
 		build_program_add_env (context->program, "LANGUAGE", "C");
 	}
 	
-	build_program_override (context->program, context->environment);
+	if (!build_program_override (context->program, context->environment))
+	{
+		build_context_destroy_command (context);
+		return FALSE;
+	}
 	
 	if (context->message_view)
 	{
diff --git a/plugins/build-basic-autotools/program.c b/plugins/build-basic-autotools/program.c
index 3f32e13..a7a9c1e 100644
--- a/plugins/build-basic-autotools/program.c
+++ b/plugins/build-basic-autotools/program.c
@@ -249,14 +249,30 @@ build_program_remove_env (BuildProgram *prog, const gchar *name)
 	}
 }
 
-void
+gboolean
 build_program_override (BuildProgram *prog, IAnjutaEnvironment *env)
 {
 	gboolean ok;
+	GError* error = NULL;
 	
-	if (env == NULL) return;
+	if (env == NULL) return TRUE;
 	
-	ok = ianjuta_environment_override (env, &prog->work_dir, &prog->argv, &prog->envp, NULL);
+	ok = ianjuta_environment_override (env, &prog->work_dir, &prog->argv, &prog->envp, &error);
+	if (!ok && error)
+	{
+		GtkWidget* dialog;
+		g_message ("ENV error!");
+		dialog = gtk_message_dialog_new (NULL,
+		                                 0,
+		                                 GTK_MESSAGE_ERROR,
+		                                 GTK_BUTTONS_OK,
+		                                 _("Error while setting up build environment:\n %s"),
+		                                 error->message);
+		g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+		gtk_widget_show (dialog);
+		g_error_free (error);
+	}
+	return ok;
 }	
 
 void
diff --git a/plugins/build-basic-autotools/program.h b/plugins/build-basic-autotools/program.h
index c13bd23..8a094dc 100644
--- a/plugins/build-basic-autotools/program.h
+++ b/plugins/build-basic-autotools/program.h
@@ -53,7 +53,7 @@ gboolean build_program_remove_arg (BuildProgram *proc, gint pos);
 gboolean build_program_add_env (BuildProgram *proc, const gchar *name, const gchar *value);
 gboolean build_program_remove_env (BuildProgram *proc, const gchar *name);
 
-void build_program_override (BuildProgram *proc, IAnjutaEnvironment *env);
+gboolean build_program_override (BuildProgram *proc, IAnjutaEnvironment *env);
 
 void build_program_set_callback (BuildProgram *proc, IAnjutaBuilderCallback callback, gpointer user_data);
 void build_program_callback (BuildProgram *proc, GObject *sender, IAnjutaBuilderHandle handle, GError *err); 



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