If a URL can't be loaded, we might end up with a NULL file. Handle that
case properly by creating an invalid image instead and don't crash or
complain to stderr when files are NULL.
This was broken since
0886ade182f1a958024202d5c20248d57fcdb053
A new reftest has been included. We need a reftest instead of a
CSS parser test, because the error only becomes visible when
compute()ing the actual image.
Fixes #4373
(cherry picked from commit
ac8c4245b2fb2f1fe8e660c4ad2541efb39cf3d6)
if (url->loaded_image)
return url->loaded_image;
+ if (url->file == NULL)
+ {
+ url->loaded_image = gtk_css_image_invalid_new ();
+ 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"))
{
{
GtkCssImageUrl *url1 = GTK_CSS_IMAGE_URL (image1);
GtkCssImageUrl *url2 = GTK_CSS_IMAGE_URL (image2);
+
+ /* FIXME: We don't save data: urls, so we can't compare them here */
+ if (url1->file == NULL || url2->file == NULL)
+ return FALSE;
return g_file_equal (url1->file, url2->file);
}
--- /dev/null
+#test {
+ /* The url should fail as early as possible */
+ background-image: url('data::::');
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkWindow" id="window1">
+ <property name="width_request">10</property>
+ <property name="height_request">10</property>
+ <property name="decorated">0</property>
+ </object>
+</interface>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkWindow" id="window1">
+ <property name="width_request">10</property>
+ <property name="height_request">10</property>
+ <property name="decorated">0</property>
+ <property name="name">test</property>
+ </object>
+</interface>
'css-image-aspect-ratio.css',
'css-image-aspect-ratio.ui',
'css-image-aspect-ratio.ref.ui',
+ 'css-image-broken-url.css',
+ 'css-image-broken-url.ref.ui',
+ 'css-image-broken-url.ui',
'css-image-color-aspect-ratio.css',
'css-image-color-aspect-ratio.ui',
'css-image-color-aspect-ratio.ref.ui',