From 09d01be0aae3b356c892d56d2c5f8eb5ae27a8d2 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 12 Jun 2009 21:45:52 -0400 Subject: Bug 585554 – Opening PDF attachment crashes in e_attachment_open_handle_error() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- widgets/misc/e-attachment.c | 47 ++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 30 deletions(-) (limited to 'widgets/misc') diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c index ba2811d5d9..7735be8872 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); -- cgit