From 29dc2eff25160b1357dc7ef245b55f7a1ce2c257 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Thu, 12 May 2011 20:55:00 -0700 Subject: [PATCH] Bug 656781 - More efficient way to use g_app_info_launch_uris and gnome_vfs_mime_application_launch, r=karlt --HG-- extra : rebase_source : a97c1bdaf1b45d380c3b90d9abb2507c68ab5128 --- toolkit/system/gnome/nsGIOService.cpp | 18 ++++-------------- toolkit/system/gnome/nsGnomeVFSService.cpp | 12 +++--------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/toolkit/system/gnome/nsGIOService.cpp b/toolkit/system/gnome/nsGIOService.cpp index 675ae397c1b3..94e2c9195308 100644 --- a/toolkit/system/gnome/nsGIOService.cpp +++ b/toolkit/system/gnome/nsGIOService.cpp @@ -135,22 +135,12 @@ nsGIOMimeApp::GetExpectsURIs(PRInt32* aExpects) NS_IMETHODIMP nsGIOMimeApp::Launch(const nsACString& aUri) { - char *uri = strdup(PromiseFlatCString(aUri).get()); + GList uris = { 0 }; + PromiseFlatCString flatUri(aUri); + uris.data = const_cast(flatUri.get()); - if (!uri) - return NS_ERROR_OUT_OF_MEMORY; - - GList *uris = g_list_append(NULL, uri); - - if (!uris) { - g_free(uri); - return NS_ERROR_OUT_OF_MEMORY; - } GError *error = NULL; - gboolean result = g_app_info_launch_uris(mApp, uris, NULL, &error); - - g_free(uri); - g_list_free(uris); + gboolean result = g_app_info_launch_uris(mApp, &uris, NULL, &error); if (!result) { g_warning("Cannot launch application: %s", error->message); diff --git a/toolkit/system/gnome/nsGnomeVFSService.cpp b/toolkit/system/gnome/nsGnomeVFSService.cpp index bcb7800e1706..dd964913b108 100644 --- a/toolkit/system/gnome/nsGnomeVFSService.cpp +++ b/toolkit/system/gnome/nsGnomeVFSService.cpp @@ -107,17 +107,11 @@ nsGnomeVFSMimeApp::Launch(const nsACString &aUri) if (! uri) return NS_ERROR_FAILURE; - GList *uris = g_list_append(NULL, uri); - - if (! uris) { - g_free(uri); - return NS_ERROR_FAILURE; - } - - GnomeVFSResult result = gnome_vfs_mime_application_launch(mApp, uris); + GList uris = { 0 }; + uris.data = uri; + GnomeVFSResult result = gnome_vfs_mime_application_launch(mApp, &uris); g_free(uri); - g_list_free(uris); if (result != GNOME_VFS_OK) return NS_ERROR_FAILURE;