From 87f5ce1c55b1e7747a29758d62913047be1b30bb Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Tue, 15 Jul 2008 00:36:26 +0200 Subject: [PATCH] Ensure SourceView really works with a valid file. --- midori/midori-browser.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index d420ada5..44324231 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -1827,18 +1827,24 @@ _action_source_view_activate (GtkAction* action, return; uri = midori_web_view_get_display_uri (MIDORI_WEB_VIEW (web_view)); + contents = NULL; + tag = NULL; #if GLIB_CHECK_VERSION (2, 16, 0) file = g_file_new_for_uri (uri); - contents = NULL; - g_file_load_contents (file, NULL, &contents, NULL, &tag, NULL); #ifdef HAVE_GTKSOURCEVIEW - info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, - G_FILE_QUERY_INFO_NONE, NULL, NULL); - content_type = info ? g_file_info_get_content_type (info) : NULL; + content_type = NULL; #endif - g_object_unref (file); + if (g_file_load_contents (file, NULL, &contents, NULL, &tag, NULL)) + { + #ifdef HAVE_GTKSOURCEVIEW + info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, + G_FILE_QUERY_INFO_NONE, NULL, NULL); + content_type = g_file_info_get_content_type (info); + #endif + g_object_unref (file); + } if (contents && !g_utf8_validate (contents, -1, NULL)) { contents_utf8 = g_convert (contents, -1, "UTF-8", "ISO-8859-1",