diff --git a/ChangeLog b/ChangeLog
index c661d9e7da0903f88f5d1ed655931b0b51516c23..fea3e8551bdcbb9a3fa29dabfea95bfe0d83b7f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-09-29  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/build.c, doc/pluginsignals.c:
+   When saving on build, prompt for a filename if necessary.
+   Emit the "build-start" signal only if saving succeeds.
+
+
 2011-09-21  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
 
  * src/build.c:
diff --git a/doc/pluginsignals.c b/doc/pluginsignals.c
index 5bc76fe121f23eba178b219cb031efa056ac9a87..bcf175b5b8ad0870ce247462019b6fafc5de4ad1 100644
--- a/doc/pluginsignals.c
+++ b/doc/pluginsignals.c
@@ -187,7 +187,7 @@ signal void (*project_dialog_confirmed)(GObject *obj, GtkWidget *notebook, gpoin
  */
 signal void (*geany_startup_complete)(GObject *obj, gpointer user_data);
 
-/** Sent before build is started. Plugins can use this signal e.g. to save the opened documents
+/** Sent before build is started. A plugin could use this signal e.g. to save all unsaved documents
  *  before the build starts.
  *
  *  @param obj a GeanyObject instance, should be ignored.
diff --git a/src/build.c b/src/build.c
index fe95637ab3999022d93049a62231dcf8301fee1f..82970f6c70da7496159f35e1b15eac983e2b8864 100644
--- a/src/build.c
+++ b/src/build.c
@@ -1272,10 +1272,16 @@ static void on_build_menu_item(GtkWidget *w, gpointer user_data)
 	gint grp = GPOINTER_TO_GRP(user_data);
 	gint cmd = GPOINTER_TO_CMD(user_data);
 
+	if (doc && doc->changed)
+	{
+		if (document_need_save_as(doc) && !dialogs_show_save_as())
+			return;
+			
+		if (!document_save_file(doc, FALSE))
+			return;
+	}
 	g_signal_emit_by_name(geany_object, "build-start");
 
-	if (doc && doc->changed)
-		document_save_file(doc, FALSE);
 	if (grp == GEANY_GBG_NON_FT && cmd == GBO_TO_CMD(GEANY_GBO_CUSTOM))
 	{
 		static GtkWidget *dialog = NULL; /* keep dialog for combo history */