picture: Don't cause warnings on load failures

When a file set via gtk_picture_set_file() can't be loaded, just
silently don't load it.

Reftest picture-load-invalid-file added for that case.
This commit is contained in:
Benjamin Otte 2019-03-29 05:36:12 +01:00
parent bf2a93ca0e
commit 7918eaf677
4 changed files with 27 additions and 1 deletions

View File

@ -604,6 +604,7 @@ load_scalable_with_loader (GFile *file,
out2:
g_bytes_unref (bytes);
out1:
gdk_pixbuf_loader_close (loader, NULL);
g_object_unref (loader);
return result;
@ -637,7 +638,7 @@ gtk_picture_set_file (GtkPicture *self,
paintable = load_scalable_with_loader (file, gtk_widget_get_scale_factor (GTK_WIDGET (self)));
gtk_picture_set_paintable (self, paintable);
g_object_unref (paintable);
g_clear_object (&paintable);
g_object_thaw_notify (G_OBJECT (self));
}

View File

@ -328,6 +328,8 @@ testdata = [
'paned-undersized.css',
'paned-undersized.ref.ui',
'paned-undersized.ui',
'picture-load-invalid-file.ui',
'picture-load-invalid-file.ref.ui',
'pseudoclass-on-box.css',
'pseudoclass-on-box.ref.ui',
'pseudoclass-on-box.ui',

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkWindow" id="window1">
<property name="type">popup</property>
<child>
<object class="GtkPicture">
</object>
</child>
</object>
</interface>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkWindow" id="window1">
<property name="type">popup</property>
<child>
<object class="GtkPicture">
<property name="file">does://not.com/exist.png</property>
</object>
</child>
</object>
</interface>