diff options
author | Benjamin Otte <otte@redhat.com> | 2023-05-12 19:20:58 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2023-05-16 18:53:27 +0200 |
commit | ee6ef41e715d3ea373c32e2bcd4d05e36d2534e8 (patch) | |
tree | 149d5bdb643428dc5539400e79fe7721570b33ea | |
parent | fde3d2cd50585ec2abef1313fbf4cd189c88a2a1 (diff) | |
download | gtk+-ee6ef41e715d3ea373c32e2bcd4d05e36d2534e8.tar.gz |
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.
-rw-r--r-- | gtk/gtkcssimageurl.c | 16 | ||||
-rw-r--r-- | testsuite/css/parser/meson.build | 2 | ||||
-rw-r--r-- | testsuite/css/parser/resource-url.css | 3 | ||||
-rw-r--r-- | testsuite/css/parser/resource-url.ref.css | 7 |
4 files changed, 13 insertions, 15 deletions
diff --git a/gtk/gtkcssimageurl.c b/gtk/gtkcssimageurl.c index d6a03c3483..d0dbe2a26c 100644 --- a/gtk/gtkcssimageurl.c +++ b/gtk/gtkcssimageurl.c @@ -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) { diff --git a/testsuite/css/parser/meson.build b/testsuite/css/parser/meson.build index b59ad993c8..b05efb7fd2 100644 --- a/testsuite/css/parser/meson.build +++ b/testsuite/css/parser/meson.build @@ -466,6 +466,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', diff --git a/testsuite/css/parser/resource-url.css b/testsuite/css/parser/resource-url.css new file mode 100644 index 0000000000..04541160e2 --- /dev/null +++ b/testsuite/css/parser/resource-url.css @@ -0,0 +1,3 @@ +window { background-image: url("resource://"); } + +button { background-image: url("resource://doesnotexist.jpg"); } diff --git a/testsuite/css/parser/resource-url.ref.css b/testsuite/css/parser/resource-url.ref.css new file mode 100644 index 0000000000..439229a509 --- /dev/null +++ b/testsuite/css/parser/resource-url.ref.css @@ -0,0 +1,7 @@ +window { + background-image: none /* invalid image */; +} + +button { + background-image: none /* invalid image */; +} |