[gedit] Fixed handling error messages for streams



commit 608511e56d32c23cdcc87a2b185877a977e3e868
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Sun May 16 20:41:48 2010 +0200

    Fixed handling error messages for streams
    
    This includes reading from stdin or a named pipe (in case of
    the gedit single process needing to read stdin from another gedit
    process)

 gedit/gedit-io-error-message-area.c |   28 ++++++++++++++++++++--------
 gedit/gedit-tab.c                   |   13 ++++++++++---
 2 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/gedit/gedit-io-error-message-area.c b/gedit/gedit-io-error-message-area.c
index fd8d462..3d04395 100644
--- a/gedit/gedit-io-error-message-area.c
+++ b/gedit/gedit-io-error-message-area.c
@@ -229,10 +229,13 @@ parse_gio_error (gint          code,
 		break;
 	case G_IO_ERROR_NOT_SUPPORTED:
 		{
-			gchar *scheme_string;
+			gchar *scheme_string = NULL;
 			gchar *scheme_markup;
-			
-			scheme_string = g_file_get_uri_scheme (location);
+
+			if (location)
+			{
+				scheme_string = g_file_get_uri_scheme (location);
+			}
 
 			if ((scheme_string != NULL) && g_utf8_validate (scheme_string, -1, NULL))
 			{
@@ -282,9 +285,12 @@ parse_gio_error (gint          code,
 		 */
 		{
 			gchar *hn = NULL;
-			gchar *uri;
+			gchar *uri = NULL;
 
-			uri = g_file_get_uri (location);
+			if (location)
+			{
+				uri = g_file_get_uri (location);
+			}
 
 			if (uri && gedit_utils_decode_uri (uri, NULL, NULL, &hn, NULL, NULL))
 			{
@@ -616,13 +622,19 @@ gedit_io_loading_error_message_area_new (GFile               *location,
 	gboolean edit_anyway = FALSE;
 	gboolean convert_error = FALSE;
 	
-	g_return_val_if_fail (G_IS_FILE (location), NULL);
 	g_return_val_if_fail (error != NULL, NULL);
 	g_return_val_if_fail ((error->domain == G_CONVERT_ERROR) ||
 			      (error->domain == GEDIT_DOCUMENT_ERROR) ||
 			      (error->domain == G_IO_ERROR), NULL);
-	
-	full_formatted_uri = gedit_utils_uri_for_display (location);
+
+	if (location)
+	{
+		full_formatted_uri = gedit_utils_uri_for_display (location);
+	}
+	else
+	{
+		full_formatted_uri = g_strdup ("stdin");
+	}
 
 	/* Truncate the URI so it doesn't get insanely wide. Note that even
 	 * though the dialog uses wrapped text, if the URI doesn't contain
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index 7c178ac..d32329a 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -517,11 +517,12 @@ io_loading_error_message_area_response (GtkWidget *message_area,
 	g_return_if_fail (GEDIT_IS_VIEW (view));
 
 	location = gedit_document_get_location (doc);
-	g_return_if_fail (location != NULL);
 
 	switch (response_id)
 	{
 		case GTK_RESPONSE_OK:
+			g_return_if_fail (location != NULL);
+
 			encoding = gedit_conversion_error_message_area_get_encoding (
 					GTK_WIDGET (message_area));
 
@@ -552,13 +553,19 @@ io_loading_error_message_area_response (GtkWidget *message_area,
 			set_message_area (tab, NULL);
 			break;
 		default:
-			_gedit_recent_remove (GEDIT_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab))), location);
+			if (location != NULL)
+			{
+				_gedit_recent_remove (GEDIT_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab))), location);
+			}
 
 			remove_tab (tab);
 			break;
 	}
 
-	g_object_unref (location);
+	if (location != NULL)
+	{
+		g_object_unref (location);
+	}
 }
 
 static void 



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