mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
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:
parent
bf2a93ca0e
commit
7918eaf677
@ -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));
|
||||
}
|
||||
|
@ -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',
|
||||
|
11
testsuite/reftests/picture-load-invalid-file.ref.ui
Normal file
11
testsuite/reftests/picture-load-invalid-file.ref.ui
Normal 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>
|
12
testsuite/reftests/picture-load-invalid-file.ui
Normal file
12
testsuite/reftests/picture-load-invalid-file.ui
Normal 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>
|
Loading…
Reference in New Issue
Block a user