After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 789870 - gtk+4, GtkWindow: Several bugs when icon became a cairo_surface_t
gtk+4, GtkWindow: Several bugs when icon became a cairo_surface_t
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.92.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2017-11-03 15:13 UTC by Kjell Ahlstedt
Modified: 2017-11-03 19:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch: GtkWindow: Tidy up after icon became a cairo surface (1.93 KB, patch)
2017-11-03 15:58 UTC, Kjell Ahlstedt
committed Details | Review

Description Kjell Ahlstedt 2017-11-03 15:13:00 UTC
gtkwindow.c was not enough modified when the window icon was changed from a
GdkPixbuf to a cairo_surface_t.

gtk_window_set_property(), case PROP_ICON:
  g_value_get_object() shall be g_value_get_boxed().

gtk_window_get_property(), case PROP_ICON:
  g_value_set_object() shall be g_value_set_boxed().

icon_from_list():
  Callers expect this function to add a reference to the returned icon,
  but this is missing in one place. Change
    best = (cairo_surface_t *)list->data;
  to
    best = cairo_surface_reference ((cairo_surface_t *)list->data);

gtk_window_set_icon():
    g_return_if_fail (icon == NULL);
  makes it impossible to set an icon with this function. Either remove that
  statement or replace it with
    g_return_if_fail (icon == NULL ||
      cairo_surface_get_type (icon) == CAIRO_SURFACE_TYPE_IMAGE);
  in analogy with what gtk_window_set_default_icon() does.
Comment 1 Emmanuele Bassi (:ebassi) 2017-11-03 15:20:33 UTC
Thanks for your bug report.

Care to prepare a patch fixing all the instances you've identified? That would speed up fixing the issue.
Comment 2 Kjell Ahlstedt 2017-11-03 15:58:43 UTC
Created attachment 362915 [details] [review]
patch: GtkWindow: Tidy up after icon became a cairo surface

This patch replaces g_return_if_fail (icon == NULL); with
  g_return_if_fail (icon == NULL ||
    cairo_surface_get_type (icon) == CAIRO_SURFACE_TYPE_IMAGE);
If you prefer to have it removed, I can make a new patch.
Comment 3 Matthias Clasen 2017-11-03 17:34:02 UTC
Review of attachment 362915 [details] [review]:

thanks, looks good