Merge branch 'wip/otte/for-master' into 'master'

icontheme: Fix variable mixup leading to crashes

Closes #4269

See merge request GNOME/gtk!3967
This commit is contained in:
Matthias Clasen 2021-09-17 18:06:30 +00:00
commit aad6b2d279
6 changed files with 76 additions and 14 deletions

View File

@ -4109,7 +4109,7 @@ gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self,
GtkTextDirection direction, GtkTextDirection direction,
GtkIconLookupFlags flags) GtkIconLookupFlags flags)
{ {
GtkIconPaintable *icon = NULL; GtkIconPaintable *paintable = NULL;
g_return_val_if_fail (GTK_IS_ICON_THEME (self), NULL); g_return_val_if_fail (GTK_IS_ICON_THEME (self), NULL);
g_return_val_if_fail (G_IS_ICON (gicon), NULL); g_return_val_if_fail (G_IS_ICON (gicon), NULL);
@ -4123,42 +4123,42 @@ gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self,
if (GDK_IS_TEXTURE (gicon)) if (GDK_IS_TEXTURE (gicon))
{ {
icon = icon_paintable_new (NULL, size, scale); paintable = icon_paintable_new (NULL, size, scale);
icon->texture = g_object_ref (GDK_TEXTURE (icon)); paintable->texture = g_object_ref (GDK_TEXTURE (gicon));
} }
else if (GDK_IS_PIXBUF (gicon)) else if (GDK_IS_PIXBUF (gicon))
{ {
icon = icon_paintable_new (NULL, size, scale); paintable = icon_paintable_new (NULL, size, scale);
icon->texture = gdk_texture_new_for_pixbuf (GDK_PIXBUF (icon)); paintable->texture = gdk_texture_new_for_pixbuf (GDK_PIXBUF (gicon));
} }
else if (G_IS_FILE_ICON (gicon)) else if (G_IS_FILE_ICON (gicon))
{ {
GFile *file = g_file_icon_get_file (G_FILE_ICON (gicon)); GFile *file = g_file_icon_get_file (G_FILE_ICON (gicon));
icon = gtk_icon_paintable_new_for_file (file, size, scale); paintable = gtk_icon_paintable_new_for_file (file, size, scale);
} }
else if (G_IS_LOADABLE_ICON (gicon)) else if (G_IS_LOADABLE_ICON (gicon))
{ {
icon = icon_paintable_new (NULL, size, scale); paintable = icon_paintable_new (NULL, size, scale);
icon->loadable = G_LOADABLE_ICON (g_object_ref (gicon)); paintable->loadable = G_LOADABLE_ICON (g_object_ref (gicon));
icon->is_svg = FALSE; paintable->is_svg = FALSE;
} }
else if (G_IS_THEMED_ICON (gicon)) else if (G_IS_THEMED_ICON (gicon))
{ {
const char **names; const char **names;
names = (const char **) g_themed_icon_get_names (G_THEMED_ICON (gicon)); names = (const char **) g_themed_icon_get_names (G_THEMED_ICON (gicon));
icon = gtk_icon_theme_lookup_icon (self, names[0], &names[1], size, scale, direction, flags); paintable = gtk_icon_theme_lookup_icon (self, names[0], &names[1], size, scale, direction, flags);
} }
else else
{ {
g_debug ("Unhandled GIcon type %s", G_OBJECT_TYPE_NAME (gicon)); g_debug ("Unhandled GIcon type %s", G_OBJECT_TYPE_NAME (gicon));
icon = icon_paintable_new ("image-missing", size, scale); paintable = icon_paintable_new ("image-missing", size, scale);
icon->filename = g_strdup (IMAGE_MISSING_RESOURCE_PATH); paintable->filename = g_strdup (IMAGE_MISSING_RESOURCE_PATH);
icon->is_resource = TRUE; paintable->is_resource = TRUE;
} }
return icon; return paintable;
} }
/** /**

View File

@ -370,6 +370,8 @@ testdata = [
'partial-rounded-border.ui', 'partial-rounded-border.ui',
'picture-load-invalid-file.ui', 'picture-load-invalid-file.ui',
'picture-load-invalid-file.ref.ui', 'picture-load-invalid-file.ref.ui',
'pixbuf-icon.ref.ui',
'pixbuf-icon.ui',
'pseudoclass-on-box.css', 'pseudoclass-on-box.css',
'pseudoclass-on-box.ref.ui', 'pseudoclass-on-box.ref.ui',
'pseudoclass-on-box.ui', 'pseudoclass-on-box.ui',
@ -423,6 +425,8 @@ testdata = [
'symbolic-icon-translucent-color.css', 'symbolic-icon-translucent-color.css',
'symbolic-icon-translucent-color.ref.ui', 'symbolic-icon-translucent-color.ref.ui',
'symbolic-icon-translucent-color.ui', 'symbolic-icon-translucent-color.ui',
'texture-icon.ref.ui',
'texture-icon.ui',
'textview-border-windows.css', 'textview-border-windows.css',
'textview-border-windows.ref.ui', 'textview-border-windows.ref.ui',
'textview-border-windows.ui', 'textview-border-windows.ui',

View File

@ -0,0 +1,13 @@
<?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>
<child>
<object class="GtkImage">
<property name="paintable">resource:///org/gtk/libgtk/icons/16x16/status/image-missing.png</property>
</object>
</child>
</object>
</interface>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkCellRendererPixbuf" id="just-creating-a-pixbuf">
<property name="pixbuf-expander-open">resource:///org/gtk/libgtk/icons/16x16/status/image-missing.png</property>
</object>
<object class="GtkWindow" id="window1">
<property name="width_request">10</property>
<property name="height_request">10</property>
<property name="decorated">0</property>
<child>
<object class="GtkImage">
<property name="gicon" bind-source="just-creating-a-pixbuf" bind-property="pixbuf-expander-open" bind-flags="sync-create"/>
</object>
</child>
</object>
</interface>

View File

@ -0,0 +1,13 @@
<?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>
<child>
<object class="GtkImage">
<property name="paintable">resource:///org/gtk/libgtk/icons/16x16/status/image-missing.png</property>
</object>
</child>
</object>
</interface>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkImage" id="just-creating-a-texture">
<property name="paintable">resource:///org/gtk/libgtk/icons/16x16/status/image-missing.png</property>
</object>
<object class="GtkWindow" id="window1">
<property name="width_request">10</property>
<property name="height_request">10</property>
<property name="decorated">0</property>
<child>
<object class="GtkImage">
<property name="gicon" bind-source="just-creating-a-texture" bind-property="paintable" bind-flags="sync-create"/>
</object>
</child>
</object>
</interface>