RESOLVED FIXED 210745
[GTK4] Adapt to GtkIconTheme API changes
https://bugs.webkit.org/show_bug.cgi?id=210745
Summary [GTK4] Adapt to GtkIconTheme API changes
Claudio Saavedra
Reported 2020-04-20 07:25:22 PDT
[GTK4] Adapt to GtkIconTheme API changes
Attachments
Patch (3.64 KB, patch)
2020-04-20 07:30 PDT, Claudio Saavedra
no flags
Patch (4.05 KB, patch)
2020-04-21 02:49 PDT, Claudio Saavedra
no flags
Claudio Saavedra
Comment 1 2020-04-20 07:30:59 PDT
Darin Adler
Comment 2 2020-04-20 10:16:03 PDT
Comment on attachment 396974 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=396974&action=review Not a GTK expert, but expert enough to review this I think. > Source/WebCore/platform/graphics/gtk/ImageGtk.cpp:69 > + GRefPtr<GtkIconPaintable> iconPaintable = adoptGRef(gtk_icon_theme_lookup_icon(gtk_icon_theme_get_for_display(gdk_display_get_default()), "image-missing", nullptr, 16, scale, gtk_widget_get_default_direction(), static_cast<GtkIconLookupFlags>(0)); > + if (iconPaintable) { I suggest using auto and putting local variable definition inside the if > Source/WebCore/platform/graphics/gtk/ImageGtk.cpp:71 > + GFile* file = gtk_icon_paintable_get_file(iconPaintable.get()); > + if (file) { Ditto. > Source/WebCore/platform/graphics/gtk/ImageGtk.cpp:73 > + auto buffer = loadResourceSharedBuffer(g_file_peek_path(file)); > + icon->setData(WTFMove(buffer), true); Given there’s no failure checking here, I would have done it as a one-liner. > Source/WebCore/platform/graphics/gtk/ImageGtk.cpp:80 > GRefPtr<GtkIconInfo> iconInfo = adoptGRef(gtk_icon_theme_lookup_icon(gtk_icon_theme_get_default(), "image-missing", iconSize, GTK_ICON_LOOKUP_NO_SVG)); > if (iconInfo) { Ditto. > Source/WebCore/platform/graphics/gtk/ImageGtk.cpp:82 > auto buffer = loadResourceSharedBuffer(gtk_icon_info_get_filename(iconInfo.get())); > icon->setData(WTFMove(buffer), true); Ditto.
Adrian Perez
Comment 3 2020-04-20 10:36:01 PDT
Comment on attachment 396974 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=396974&action=review > Source/WebCore/platform/graphics/gtk/ImageGtk.cpp:70 > + GFile* file = gtk_icon_paintable_get_file(iconPaintable.get()); We need a GRefPtr<GFile> here to avoid leaking the object. The _get_file() accessor is “transfer full”. You could even do: if (auto file = adoptGRef(gtk_icon_paintable_get_file(iconPaintable.get()))) { // Load data from file. } =)
Darin Adler
Comment 4 2020-04-20 10:51:00 PDT
Very happy to see the adoptGRef recommendations.
Carlos Garcia Campos
Comment 5 2020-04-21 01:24:38 PDT
Comment on attachment 396974 [details] Patch I would just remove this code for both GTK3 and GTK4 and always use the missingImage we already compile as a GResource.
Claudio Saavedra
Comment 6 2020-04-21 02:49:20 PDT
Adrian Perez
Comment 7 2020-04-21 04:34:03 PDT
Comment on attachment 397065 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=397065&action=review > Source/WebCore/platform/graphics/gtk/ImageGtk.cpp:53 > + return loadImageFromGResource(name); Oh, much nicer! Thanks Carlos for remembering that we had an image for this in the resource bundle already =)
EWS
Comment 8 2020-04-21 05:31:26 PDT
Committed r260425: <https://trac.webkit.org/changeset/260425> All reviewed patches have been landed. Closing bug and clearing flags on attachment 397065 [details].
Note You need to log in before you can comment on or make changes to this bug.