diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/caja-places-sidebar.c | 20 | ||||
| -rw-r--r-- | src/glibcompat.h | 18 | 
2 files changed, 23 insertions, 15 deletions
| diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index fa588663..88e7d1c1 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -53,7 +53,7 @@  #include "caja-places-sidebar.h"  #include "caja-window.h" -#include "glibcompat.h" /* for g_list_free_full */ +#include "glibcompat.h" /* for g_list_free_full and g_clear_object */  #define EJECT_BUTTON_XPAD 6  #define ICON_CELL_XPAD 6 @@ -3332,20 +3332,10 @@ caja_places_sidebar_dispose (GObject *object)          sidebar->eject_highlight_path = NULL;      } -    if (sidebar->store != NULL) { -        g_object_unref (sidebar->store); -        sidebar->store = NULL; -    } - -    if (sidebar->volume_monitor != NULL) { -        g_object_unref (sidebar->volume_monitor); -        sidebar->volume_monitor = NULL; -    } - -    if (sidebar->bookmarks != NULL) { -        g_object_unref (sidebar->bookmarks); -        sidebar->bookmarks = NULL; -    } +    g_clear_object (&sidebar->store); +    g_clear_object (&sidebar->volume_monitor); +    g_clear_object (&sidebar->bookmarks); +    g_clear_object (&sidebar->filter_model);      eel_remove_weak_pointer (&(sidebar->go_to_after_mount_slot)); diff --git a/src/glibcompat.h b/src/glibcompat.h index a83da239..4c71b2b5 100644 --- a/src/glibcompat.h +++ b/src/glibcompat.h @@ -38,4 +38,22 @@ g_list_free_full (GList *list, GDestroyNotify free_func)  }  #endif +#if !GLIB_CHECK_VERSION(2,28,0) +static inline void +g_clear_object_inline(volatile GObject **object_ptr) +{ +    gpointer * const ptr = (gpointer)object_ptr; +    gpointer old; + +    do { +        old = g_atomic_pointer_get(ptr); +    } while G_UNLIKELY(!g_atomic_pointer_compare_and_exchange(ptr, old, NULL)); + +    if (old) +        g_object_unref(old); +} +#undef  g_clear_object +#define g_clear_object(obj) g_clear_object_inline((volatile GObject **)(obj)) +#endif +  #endif /* GLIB_COMPAT_H */ | 
