[gtksourceview/gnome-3-6] Actually we can use weak pointer
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/gnome-3-6] Actually we can use weak pointer
- Date: Sun, 4 Nov 2012 11:41:47 +0000 (UTC)
commit b54d7c974caaa690cc7c02d6c117c917c2368d13
Author: Paolo Borelli <pborelli gnome org>
Date: Sat Nov 3 21:26:48 2012 +0100
Actually we can use weak pointer
I didn't see remove_weak_pointer before...
gtksourceview/gtksourcegutterrenderer.c | 13 ++++---------
1 files changed, 4 insertions(+), 9 deletions(-)
---
diff --git a/gtksourceview/gtksourcegutterrenderer.c b/gtksourceview/gtksourcegutterrenderer.c
index dafe17d..06f26a0 100644
--- a/gtksourceview/gtksourcegutterrenderer.c
+++ b/gtksourceview/gtksourcegutterrenderer.c
@@ -82,25 +82,20 @@ enum
PROP_BACKGROUND_SET
};
-/* we cannot simply use g_object_add_weak_pointer
- * because if the buffer is finalized after the renderer, glib
- * will try to nullify freed memory, so we need to unref first */
static void
set_buffer (GtkSourceGutterRenderer *renderer,
GtkTextBuffer *buffer)
{
if (renderer->priv->buffer != NULL)
{
- g_object_weak_unref (G_OBJECT (renderer->priv->buffer),
- (GWeakNotify) g_nullify_pointer,
- (gpointer)&renderer->priv->buffer);
+ g_object_remove_weak_pointer (G_OBJECT (renderer->priv->buffer),
+ &renderer->priv->buffer);
}
if (buffer != NULL)
{
- g_object_weak_ref (G_OBJECT (buffer),
- (GWeakNotify) g_nullify_pointer,
- (gpointer)&renderer->priv->buffer);
+ g_object_add_weak_pointer (G_OBJECT (renderer->priv->buffer),
+ &renderer->priv->buffer);
}
renderer->priv->buffer = buffer;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]