diff options
-rw-r--r-- | modules/engines/pixbuf/pixbuf-render.c | 21 | ||||
-rw-r--r-- | modules/engines/pixbuf/pixbuf.h | 1 |
2 files changed, 20 insertions, 2 deletions
diff --git a/modules/engines/pixbuf/pixbuf-render.c b/modules/engines/pixbuf/pixbuf-render.c index c05832da34..a272ff4a5e 100644 --- a/modules/engines/pixbuf/pixbuf-render.c +++ b/modules/engines/pixbuf/pixbuf-render.c @@ -524,8 +524,25 @@ theme_pixbuf_new (void) void theme_pixbuf_destroy (ThemePixbuf *theme_pb) { - theme_pixbuf_set_filename (theme_pb, NULL); - g_free (theme_pb); + if (G_LIKELY (theme_pb)) + { + theme_pixbuf_set_filename (theme_pb, NULL); + g_free (theme_pb); + } +} + +void +theme_clear_pixbuf (ThemePixbuf **theme_pb) +{ +#if GLIB_CHECK_VERSION (2, 34, 0) + g_clear_pointer (theme_pb, theme_pixbuf_destroy); +#else + if (*theme_pb) + { + theme_pixbuf_destroy (*theme_pb); + *theme_pb = NULL; + } +#endif } void diff --git a/modules/engines/pixbuf/pixbuf.h b/modules/engines/pixbuf/pixbuf.h index d0c74e9159..c656c6fd81 100644 --- a/modules/engines/pixbuf/pixbuf.h +++ b/modules/engines/pixbuf/pixbuf.h @@ -195,6 +195,7 @@ struct _ThemeImage G_GNUC_INTERNAL ThemePixbuf *theme_pixbuf_new (void); G_GNUC_INTERNAL void theme_pixbuf_destroy (ThemePixbuf *theme_pb); +G_GNUC_INTERNAL void theme_clear_pixbuf (ThemePixbuf **theme_pb); G_GNUC_INTERNAL void theme_pixbuf_set_filename (ThemePixbuf *theme_pb, const char *filename); G_GNUC_INTERNAL GdkPixbuf * theme_pixbuf_get_pixbuf (ThemePixbuf *theme_pb); |