css: Remove crashy resource:// optimization

Using gdk_texture_new_from_resource() is not valid here because we are
not sure if the given resource is valid.

Plus, the previous optimization is no longer relevant, because we are
not using gdk_pixbuf_new_from_resource() anymore - which was what this
optimization was about before it was ported to GdkTexture.

Test attached.
This commit is contained in:
Benjamin Otte 2023-05-12 19:20:58 +02:00 committed by Matthias Clasen
parent 49d06736a5
commit 41696b0c57
4 changed files with 13 additions and 15 deletions

View File

@ -47,21 +47,7 @@ gtk_css_image_url_load_image (GtkCssImageUrl *url,
return url->loaded_image;
}
/* We special case resources here so we can use gdk_texture_new_from_resource. */
if (g_file_has_uri_scheme (url->file, "resource"))
{
char *uri = g_file_get_uri (url->file);
char *resource_path = g_uri_unescape_string (uri + strlen ("resource://"), NULL);
texture = gdk_texture_new_from_resource (resource_path);
g_free (resource_path);
g_free (uri);
}
else
{
texture = gdk_texture_new_from_file (url->file, &local_error);
}
texture = gdk_texture_new_from_file (url->file, &local_error);
if (texture == NULL)
{

View File

@ -449,6 +449,8 @@ test_data = [
'radial-positions.errors',
'radial-positions.ref.css',
'radial.ref.css',
'resource-url.css',
'resource-url.ref.css',
'rotate3d-crash.css',
'rotate3d-crash.errors',
'rotate3d-crash.ref.css',

View File

@ -0,0 +1,3 @@
window { background-image: url("resource://"); }
button { background-image: url("resource://doesnotexist.jpg"); }

View File

@ -0,0 +1,7 @@
window {
background-image: none /* invalid image */;
}
button {
background-image: none /* invalid image */;
}