[gtk+] Check if buffer is NULL after setting it to NULL, not before.



commit d688343a31dbe67f34228b998bbb753584d8d2e9
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Fri Nov 12 13:14:12 2010 +0100

    Check if buffer is NULL after setting it to NULL, not before.
    
    This catches cases when "notify::buffer" handler does not recreate
    the buffer again, which could end in reference leak.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=634677

 gtk/gtktextview.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 7d3d639..e0f42ec 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -3031,10 +3031,11 @@ gtk_text_view_finalize (GObject *object)
   text_view = GTK_TEXT_VIEW (object);
   priv = text_view->priv;
 
-  g_assert (priv->buffer == NULL);
-
   gtk_text_view_destroy_layout (text_view);
   gtk_text_view_set_buffer (text_view, NULL);
+
+  /* at this point, no "notify::buffer" handler should recreate the buffer. */
+  g_assert (priv->buffer == NULL);
   
   cancel_pending_scroll (text_view);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]