From b866d48f553b9aa7cdbe3200763d4bfc3017c943 Mon Sep 17 00:00:00 2001 From: "Pratik V. Parikh" Date: Mon, 8 Mar 2004 16:58:41 +0000 Subject: Check that app is not NULL before trying to open the quickref document. 2004-03-06 Pratik V. Parikh * e-shell-window-commands.c (command_quick_reference): Check that app is not NULL before trying to open the quickref document. Fixes #55106 svn path=/trunk/; revision=24989 --- shell/e-shell-window-commands.c | 51 +++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'shell/e-shell-window-commands.c') diff --git a/shell/e-shell-window-commands.c b/shell/e-shell-window-commands.c index 8ce97a7940..39f6390b68 100644 --- a/shell/e-shell-window-commands.c +++ b/shell/e-shell-window-commands.c @@ -188,7 +188,6 @@ command_quick_reference (BonoboUIComponent *uih, { char *quickref; char *uri; - char *mimetype; char *command; GString *str; GnomeVFSMimeApplication *app; @@ -205,35 +204,37 @@ command_quick_reference (BonoboUIComponent *uih, quickref = g_build_filename (EVOLUTION_HELPDIR, "quickref", lang, "quickref.pdf", NULL); if (g_file_test (quickref, G_FILE_TEST_EXISTS)) { - mimetype = gnome_vfs_get_mime_type (quickref); - app = gnome_vfs_mime_get_default_application (mimetype); - str = g_string_new (""); - str = g_string_append (str, app->command); - - switch (app->expects_uris) { - case GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS: - uri = g_strconcat ("file://", quickref, NULL); - g_string_append_printf (str, " %s", uri); - g_free (uri); - break; - case GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_PATHS: - case GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS_FOR_NON_FILES: - g_string_append_printf (str, " %s", quickref); - break; + app = gnome_vfs_mime_get_default_application ("application/pdf"); + if (app) { + str = g_string_new (""); + str = g_string_append (str, app->command); + + switch (app->expects_uris) { + case GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS: + uri = g_strconcat ("file://", quickref, NULL); + g_string_append_printf (str, " %s", uri); + g_free (uri); + break; + case GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_PATHS: + case GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS_FOR_NON_FILES: + g_string_append_printf (str, " %s", quickref); + break; + } + + command = g_string_free (str, FALSE); + if (command != NULL && + !g_spawn_command_line_async (command, NULL)) { + g_warning ("Could not launch %s", command); + } + + g_free (command); + gnome_vfs_mime_application_free (app); } - command = g_string_free (str, FALSE); - if (command != NULL && - !g_spawn_command_line_async (command, NULL)) { - g_warning ("Could not launch %s", command); - } - g_free (command); - - gnome_vfs_mime_application_free (app); - g_free (mimetype); g_free (quickref); return; } + g_free (quickref); } } -- cgit v1.2.3