diff options
author | Bastien Nocera <hadess@hadess.net> | 2011-08-26 16:36:12 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2011-08-30 15:55:02 +0100 |
commit | 229234111c418c2186868c47bfdd6684be8ee1cf (patch) | |
tree | 87cfc3026ce4309d9e80a26020f043ec01fe4e53 | |
parent | 619b77319619d84523866fd11e2cc484b470ed80 (diff) |
gio: Error out when we cannot modify a GAppInfo
g_desktop_app_info_set_as_default_for_type() and
g_desktop_app_info_set_as_last_used_for_type () require the
application's ID, but depending on how the GAppInfo was created,
we might not be have one, and would thus silently fail to set
the default application, or last used application.
https://bugzilla.gnome.org/show_bug.cgi?id=657445
-rw-r--r-- | gio/gdesktopappinfo.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c index 6bd6a0d03..64f03495f 100644 --- a/gio/gdesktopappinfo.c +++ b/gio/gdesktopappinfo.c @@ -1779,6 +1779,13 @@ g_desktop_app_info_set_as_last_used_for_type (GAppInfo *appinfo, if (!g_desktop_app_info_ensure_saved (info, error)) return FALSE; + if (!info->desktop_id) + { + g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, + _("Application information lacks an identifier")); + return FALSE; + } + /* both add support for the content type and set as last used */ return update_mimeapps_list (info->desktop_id, content_type, UPDATE_MIME_SET_NON_DEFAULT | @@ -1794,8 +1801,15 @@ g_desktop_app_info_set_as_default_for_type (GAppInfo *appinfo, GDesktopAppInfo *info = G_DESKTOP_APP_INFO (appinfo); if (!g_desktop_app_info_ensure_saved (info, error)) - return FALSE; - + return FALSE; + + if (!info->desktop_id) + { + g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, + _("Application information lacks an identifier")); + return FALSE; + } + return update_mimeapps_list (info->desktop_id, content_type, UPDATE_MIME_SET_DEFAULT, error); |