diff -urNp anjuta-2.24.2.orig/libanjuta/anjuta-shell.c anjuta-2.24.2/libanjuta/anjuta-shell.c
--- anjuta-2.24.2.orig/libanjuta/anjuta-shell.c	2009-03-16 01:11:44.000000000 +0530
+++ anjuta-2.24.2/libanjuta/anjuta-shell.c	2009-03-16 02:28:29.000000000 +0530
@@ -754,6 +754,36 @@ anjuta_shell_get_profile_manager (Anjuta
 	return ANJUTA_SHELL_GET_IFACE (shell)->get_profile_manager (shell, error);
 }
 
+/**
+ * anjuta_shell_saving_push:
+ * @shell: A #AnjutaShell interface
+ *
+ * Increase the count of files that need to be saved
+ *
+ */
+void
+anjuta_shell_saving_push (AnjutaShell* shell)
+{
+	g_return_if_fail (ANJUTA_IS_SHELL (shell));
+
+	return ANJUTA_SHELL_GET_IFACE (shell)->saving_push (shell);
+}
+
+/**
+ * anjuta_shell_saving_pop:
+ * @shell: A #AnjutaShell interface
+ *
+ * Decrease the count of files that need to be saved
+ *
+ */
+void
+anjuta_shell_saving_pop (AnjutaShell* shell)
+{
+	g_return_if_fail (ANJUTA_IS_SHELL (shell));
+
+	return ANJUTA_SHELL_GET_IFACE (shell)->saving_pop (shell);
+}
+
 void
 anjuta_shell_session_save (AnjutaShell *shell, const gchar *session_directory,
 						   GError **error)
diff -urNp anjuta-2.24.2.orig/libanjuta/anjuta-shell.h anjuta-2.24.2/libanjuta/anjuta-shell.h
--- anjuta-2.24.2.orig/libanjuta/anjuta-shell.h	2009-03-16 01:11:44.000000000 +0530
+++ anjuta-2.24.2/libanjuta/anjuta-shell.h	2009-03-16 02:28:29.000000000 +0530
@@ -108,6 +108,8 @@ struct _AnjutaShellIface {
 	void (*remove_value)      (AnjutaShell  *shell,
 							   const char   *name,
 							   GError       **error);
+	void (*saving_push)       (AnjutaShell  *shell);
+	void (*saving_pop)        (AnjutaShell  *shell);
 	GObject* (*get_object)    (AnjutaShell  *shell,
 							   const char   *iface_name,
 							   GError       **error);
@@ -196,6 +198,8 @@ void anjuta_shell_save_prompt       (Anj
 									 AnjutaSavePrompt *prompt,
 									 GError **error);
 void anjuta_shell_notify_exit       (AnjutaShell *shell, GError **error);
+void anjuta_shell_saving_push       (AnjutaShell *shell);
+void anjuta_shell_saving_pop        (AnjutaShell *shell);
 
 /**
  * anjuta_shell_get_interface:
diff -urNp anjuta-2.24.2.orig/plugins/sourceview/sourceview-io.c anjuta-2.24.2/plugins/sourceview/sourceview-io.c
--- anjuta-2.24.2.orig/plugins/sourceview/sourceview-io.c	2009-03-16 01:11:45.000000000 +0530
+++ anjuta-2.24.2/plugins/sourceview/sourceview-io.c	2009-03-16 02:36:16.000000000 +0530
@@ -213,13 +213,16 @@ set_display_name (SourceviewIO* sio)
 }
 
 static void
-on_save_finished (GObject* output_stream, GAsyncResult* result, gpointer data)
+on_save_finished (GObject* file, GAsyncResult* result, gpointer data)
 {
 	SourceviewIO* sio = SOURCEVIEW_IO(data);
+	AnjutaShell* shell = ANJUTA_PLUGIN (sio->sv->priv->plugin)->shell;
 	GError* err = NULL;
-	g_output_stream_write_finish (G_OUTPUT_STREAM(output_stream),
-								  result,
-								  &err);
+	gchar* etag;
+	g_file_replace_contents_finish (G_FILE (file),
+					result,
+					&etag,
+					&err);
 	if (err)
 	{
 		g_signal_emit_by_name (sio, "save-failed", err);
@@ -228,13 +231,13 @@ on_save_finished (GObject* output_stream
 	else
 	{
 		set_display_name (sio);
-		g_output_stream_close(G_OUTPUT_STREAM (output_stream), NULL, NULL);
 		g_signal_emit_by_name (sio, "save-finished");
 		setup_monitor (sio);
 	}
 	g_free (sio->write_buffer);
+	g_free (etag);
 	sio->write_buffer = NULL;
-	g_object_unref (output_stream);
+	anjuta_shell_saving_pop (shell);
 }
 
 void
@@ -255,38 +258,17 @@ sourceview_io_save (SourceviewIO* sio)
 void
 sourceview_io_save_as (SourceviewIO* sio, GFile* file)
 {
-	GFileOutputStream* output_stream;
-	GError* err = NULL;
+	AnjutaShell* shell = ANJUTA_PLUGIN (sio->sv->priv->plugin)->shell;
+	gsize len;
 	g_return_if_fail (file != NULL);
 	
 	cancel_monitor (sio);
 	
-	output_stream = g_file_create (file, G_FILE_CREATE_NONE, NULL, &err);
-	if (!output_stream)
-	{
-		if (err->code != G_IO_ERROR_EXISTS)
-		{
-			g_signal_emit_by_name (sio, "save-failed", err);
-			g_error_free (err);
-			return;
-		}
-		else
-		{
-			output_stream = g_file_replace (file, NULL, TRUE, G_FILE_CREATE_NONE,
-											NULL, NULL);
-			if (!output_stream)
-			{
-				g_signal_emit_by_name (sio, "save-failed", err);
-				g_error_free (err);
-				return;
-			}
-		}
-	}
-	
 	if (sio->last_encoding == NULL)
 	{
 		sio->write_buffer = ianjuta_editor_get_text_all (IANJUTA_EDITOR(sio->sv), 
 														 NULL);
+		len = strlen (sio->write_buffer);
 	}
 	else
 	{
@@ -296,7 +278,7 @@ sourceview_io_save_as (SourceviewIO* sio
 		sio->write_buffer = anjuta_convert_from_utf8 (buffer_text,
 													  -1,
 													  sio->last_encoding,
-													  NULL,
+													  &len,
 													  &err);
 		g_free (buffer_text);
 		if (err != NULL)
@@ -307,13 +289,16 @@ sourceview_io_save_as (SourceviewIO* sio
 		}
 	}
 	g_cancellable_reset (sio->cancel);
-	g_output_stream_write_async (G_OUTPUT_STREAM (output_stream),
-								 sio->write_buffer,
-								 strlen (sio->write_buffer),
-								 G_PRIORITY_LOW,
-								 sio->cancel,
-								 on_save_finished,
-								 sio);
+	g_file_replace_contents_async (file,
+				       sio->write_buffer,
+				       len,
+				       NULL,
+				       FALSE,
+				       G_FILE_CREATE_NONE,
+				       sio->cancel,
+				       on_save_finished,
+				       sio);
+	anjuta_shell_saving_push (shell);
 	
 	if (sio->file != file)
 	{
diff -urNp anjuta-2.24.2.orig/src/anjuta-app.c anjuta-2.24.2/src/anjuta-app.c
--- anjuta-2.24.2.orig/src/anjuta-app.c	2009-03-16 01:11:44.000000000 +0530
+++ anjuta-2.24.2/src/anjuta-app.c	2009-03-16 02:28:29.000000000 +0530
@@ -766,6 +766,8 @@ anjuta_app_instance_init (AnjutaApp *app
 	
 	/* Loading accels */
 	anjuta_ui_load_accels ();
+
+	app->save_count = 0;
 }
 
 static void
@@ -1036,6 +1038,20 @@ anjuta_app_remove_value (AnjutaShell *sh
 	}
 }
 
+static void
+anjuta_app_saving_push (AnjutaShell* shell)
+{
+	AnjutaApp* app = ANJUTA_APP (shell);
+	app->save_count++;
+}
+
+static void
+anjuta_app_saving_pop (AnjutaShell* shell)
+{
+	AnjutaApp* app = ANJUTA_APP (shell);
+	app->save_count--;
+}
+
 static gboolean
 remove_from_widgets_hash (gpointer name, gpointer hash_widget, gpointer widget)
 {
@@ -1319,6 +1335,8 @@ anjuta_shell_iface_init (AnjutaShellIfac
 	iface->get_preferences = anjuta_app_get_preferences;
 	iface->get_plugin_manager = anjuta_app_get_plugin_manager;
 	iface->get_profile_manager = anjuta_app_get_profile_manager;
+	iface->saving_push = anjuta_app_saving_push;
+	iface->saving_pop = anjuta_app_saving_pop;
 }
 
 ANJUTA_TYPE_BEGIN(AnjutaApp, anjuta_app, GTK_TYPE_WINDOW);
diff -urNp anjuta-2.24.2.orig/src/anjuta-app.h anjuta-2.24.2/src/anjuta-app.h
--- anjuta-2.24.2.orig/src/anjuta-app.h	2009-03-16 01:11:44.000000000 +0530
+++ anjuta-2.24.2/src/anjuta-app.h	2009-03-16 02:28:29.000000000 +0530
@@ -58,6 +58,8 @@ struct _AnjutaApp
 	AnjutaPreferences *preferences;
 	AnjutaPluginManager *plugin_manager;
 	AnjutaProfileManager *profile_manager;
+
+	gint save_count;
 	
 	/* Bonobo */
 	GtkWidget *bonobo_dock;
diff -urNp anjuta-2.24.2.orig/src/anjuta.c anjuta-2.24.2/src/anjuta.c
--- anjuta-2.24.2.orig/src/anjuta.c	2009-03-16 01:11:44.000000000 +0530
+++ anjuta-2.24.2/src/anjuta.c	2009-03-16 02:28:29.000000000 +0530
@@ -80,6 +80,15 @@ on_anjuta_delete_event (AnjutaApp *app, 
 		}
 	}
 	
+	/* Wait for files to be really saved (asyncronous operation) */
+	if (app->save_count > 0)
+	{
+		g_message ("Waiting for %d file(s) to be saved!", app->save_count);
+		while (app->save_count > 0)
+		{
+			g_main_context_iteration (NULL, TRUE);
+		}
+	}
 	/* If current active profile is "user", save current session as
 	 * default session
 	 */
