From: Benjamin Otte Date: Fri, 12 May 2023 17:20:58 +0000 (+0200) Subject: css: Remove crashy resource:// optimization X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~3^2~1^2~33 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=41696b0c575c9331bbf8ae6c622df1e4c7c9e5c9;p=gtk4.git 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. --- 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 b419c29865..4c13342c54 100644 --- a/testsuite/css/parser/meson.build +++ b/testsuite/css/parser/meson.build @@ -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', 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 */; +}