[PATCH] Scaffold -- Dont crash if project creation script fails to spawn

Rui Lopes <[email protected]>
Newsgroups gmane.comp.gnome.devtools
Message-ID <1062364678.613.229.camel@localhost>
Hi all,


In the attach are some Scaffold fixes:

* If project creation script failed to spawn, scaffold crashed.
* Don't hardcode python command path, use G_SPAWN_SEARCH_PATH
  g_spawn_xxx flag.
* errmsg/outmsg g_spawn_sync arguments were swapped.
* Schema switch `--disable-schemas-install' was being ignored.


Regards,
Rui Lopes
scaffold_create_project.patch (text/plain, 3.4 KB)
# Some Scaffold fixes:
# * If project creation script failed to spawn, scaffold crashed.
# * Don't hardcode python command path, use G_SPAWN_SEARCH_PATH
#   g_spawn_xxx flag.
# * errmsg/outmsg g_spawn_sync arguments were swapped.
# * Schema switch `--disable-schemas-install' was being ignored.
# -- Rui Lopes <[email protected]>
Index: data/Makefile.am
===================================================================
RCS file: /cvs/gnome/scaffold/data/Makefile.am,v
retrieving revision 1.6
diff -u -r1.6 Makefile.am
--- data/Makefile.am	8 Aug 2003 20:44:18 -0000	1.6
+++ data/Makefile.am	31 Aug 2003 21:05:03 -0000
@@ -30,7 +30,7 @@
 gladedir = $(datadir)/scaffold/glade/
 glade_DATA = scaffold.glade
 
-install-data-local:
+install-schemas:
 	GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$(schemas_DATA)
 
 CLEANFILES = $(schemas_DATA) $(desktop_DATA) $(schemas_DATA)
Index: plugins/gnome-project-types/scaffold-gnome-application-type.c
===================================================================
RCS file: /cvs/gnome/scaffold/plugins/gnome-project-types/scaffold-gnome-application-type.c,v
retrieving revision 1.2
diff -u -r1.2 scaffold-gnome-application-type.c
--- plugins/gnome-project-types/scaffold-gnome-application-type.c	31 Jul 2003 08:55:25 -0000	1.2
+++ plugins/gnome-project-types/scaffold-gnome-application-type.c	31 Aug 2003 21:05:03 -0000
@@ -70,16 +70,16 @@
 		     ScaffoldProjectInfo *info,
 		     GError **error)
 {
-	char **args;
-	char *scriptdir;
+	gchar **args;
+	const gchar *scriptdir;
 	GError *err = NULL;
-	int status;
-	char *errmsg, *outmsg;
+	gint status;
+	gchar *errmsg, *outmsg;
 
 	g_message ("create_project_impl");
 
-	args = g_new0 (char *, 7);
-	args[0] = g_strdup ("/usr/bin/python");
+	args = g_new (gchar *, 7);
+	args[0] = g_strdup ("python");
 	args[1] = g_strdup ("scaffold-gnome-application-create.py");
 	args[2] = g_strdup (info->name);
 	args[3] = g_strdup (info->package);
@@ -87,19 +87,25 @@
 	args[5] = g_strdup (info->location);
 	args[6] = NULL;
 
-	scriptdir = g_strconcat (DATADIR, "/scaffold/plugins/gnome-project-types", NULL);
+	scriptdir = DATADIR "/scaffold/plugins/gnome-project-types";
 	g_message (scriptdir);
 
 	/* Spawn the python project creation script. */
-	if (!g_spawn_sync (scriptdir, args, NULL, 0, NULL, NULL, &errmsg, &outmsg, &status, &err)) {
-		g_message (errmsg);
-		g_message (outmsg);
-		g_message (err->message);
-		*error = err;
+	if (!g_spawn_sync (scriptdir, args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &outmsg, &errmsg, &status, &err)) {
+		/* Spawn failed. */
 		g_message ("error spawning script");
+		g_message (err->message);
+	}
+	else {
+		/* Spawn succeeded. */
+		g_message (outmsg);
+		g_message (errmsg);
+
+		g_free (outmsg);
+		g_free (errmsg);
 	}
 
-	g_free (scriptdir);
+	*error = err;
 	g_strfreev (args);
 }
 
Index: plugins/project-manager/project-tool.c
===================================================================
RCS file: /cvs/gnome/scaffold/plugins/project-manager/project-tool.c,v
retrieving revision 1.49
diff -u -r1.49 project-tool.c
--- plugins/project-manager/project-tool.c	8 Aug 2003 20:44:21 -0000	1.49
+++ plugins/project-manager/project-tool.c	31 Aug 2003 21:05:03 -0000
@@ -377,6 +377,7 @@
 	gdl_recent_add (proj_tool->recent, filename);
 	g_free (filename);
 
+	/* XXX: this should be freed with a function i.e. scaffold_project_druid_free_info. */
 	g_free (info->name);
 	g_free (info->package);
 	g_free (info->description);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.