mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 15:36:17 +01:00
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
This commit is contained in:
parent
619b773196
commit
229234111c
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user