[evolution/kill-bonobo: 61/65] Bug 585554 – Opening PDF attachment crashes in e_attachment_open_handle_error()



commit 477736ea33b961f72a583f320632fd12c411b164
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Jun 12 21:45:52 2009 -0400

    Bug 585554 â?? Opening PDF attachment crashes in e_attachment_open_handle_error()

 widgets/misc/e-attachment.c |   47 +++++++++++++++---------------------------
 1 files changed, 17 insertions(+), 30 deletions(-)
---
diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c
index ba2811d..7735be8 100644
--- a/widgets/misc/e-attachment.c
+++ b/widgets/misc/e-attachment.c
@@ -1957,7 +1957,6 @@ attachment_open_file (GFile *file,
 {
 	GdkAppLaunchContext *context;
 	GSimpleAsyncResult *simple;
-	GList *file_list;
 	gboolean success;
 	GError *error = NULL;
 
@@ -1965,41 +1964,29 @@ attachment_open_file (GFile *file,
 	simple = open_context->simple;
 	open_context->simple = NULL;
 
-	/* Find a default app based on content type. */
-	if (open_context->app_info == NULL) {
-		EAttachment *attachment;
-		GFileInfo *file_info;
-		const gchar *content_type;
-
-		attachment = open_context->attachment;
-		file_info = e_attachment_get_file_info (attachment);
-		if (file_info == NULL)
-			goto exit;
-
-		content_type = g_file_info_get_content_type (file_info);
-		if (content_type == NULL)
-			goto exit;
+	context = gdk_app_launch_context_new ();
 
-		open_context->app_info = g_app_info_get_default_for_type (
-			content_type, FALSE);
+	if (open_context->app_info != NULL) {
+		GList *file_list;
+
+		file_list = g_list_prepend (NULL, file);
+		success = g_app_info_launch (
+			open_context->app_info, file_list,
+			G_APP_LAUNCH_CONTEXT (context), &error);
+		g_list_free (file_list);
+	} else {
+		gchar *uri;
+
+		uri = g_file_get_uri (file);
+		success = g_app_info_launch_default_for_uri (
+			uri, G_APP_LAUNCH_CONTEXT (context), &error);
+		g_free (uri);
 	}
 
-	if (open_context->app_info == NULL)
-		goto exit;
-
-	context = gdk_app_launch_context_new ();
-	file_list = g_list_prepend (NULL, file);
-
-	success = g_app_info_launch (
-		open_context->app_info, file_list,
-		G_APP_LAUNCH_CONTEXT (context), &error);
+	g_object_unref (context);
 
 	g_simple_async_result_set_op_res_gboolean (simple, success);
 
-	g_list_free (file_list);
-	g_object_unref (context);
-
-exit:
 	if (error != NULL) {
 		g_simple_async_result_set_from_error (simple, error);
 		g_error_free (error);



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