]> spindle.queued.net Git - midori/commitdiff
Ensure SourceView really works with a valid file.
authorChristian Dywan <christian@twotoasts.de>
Mon, 14 Jul 2008 22:36:26 +0000 (00:36 +0200)
committerChristian Dywan <christian@twotoasts.de>
Mon, 14 Jul 2008 22:36:26 +0000 (00:36 +0200)
midori/midori-browser.c

index d420ada57013488668928e513f5d2bcfbed7f146..44324231e258f101f9eaf06e0ab5fc99f0f95716 100644 (file)
@@ -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",