mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 10:42:11 +01:00
gresource: Remove unnecessary errors from g_resources_open_stream()
The error here can only ever be `G_RESOURCE_ERROR_NOT_FOUND`, which `g_resources_open_stream()` immediately frees. So let’s avoid allocating the error in the first place. Spotted by Christian Hergert. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Helps: #3465
This commit is contained in:
parent
a839737fc8
commit
77ba62c832
@ -763,6 +763,9 @@ do_lookup (GResource *resource,
|
||||
*
|
||||
* @lookup_flags controls the behaviour of the lookup.
|
||||
*
|
||||
* The only error this can return is %G_RESOURCE_ERROR_NOT_FOUND, if @path was
|
||||
* not found in @resource.
|
||||
*
|
||||
* Returns: (transfer full): #GInputStream or %NULL on error.
|
||||
* Free the returned object with g_object_unref()
|
||||
*
|
||||
@ -1114,18 +1117,15 @@ g_resources_open_stream (const gchar *path,
|
||||
for (l = registered_resources; l != NULL; l = l->next)
|
||||
{
|
||||
GResource *r = l->data;
|
||||
GError *my_error = NULL;
|
||||
|
||||
stream = g_resource_open_stream (r, path, lookup_flags, &my_error);
|
||||
if (stream == NULL &&
|
||||
g_error_matches (my_error, G_RESOURCE_ERROR, G_RESOURCE_ERROR_NOT_FOUND))
|
||||
stream = g_resource_open_stream (r, path, lookup_flags, NULL);
|
||||
if (stream == NULL)
|
||||
{
|
||||
g_clear_error (&my_error);
|
||||
/* g_resource_open_stream() guarantees it only fails with
|
||||
* %G_RESOURCE_ERROR_NOT_FOUND */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stream == NULL)
|
||||
g_propagate_error (error, my_error);
|
||||
res = stream;
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user