[gtkmm] Gtk::Builder: Fix ref count in get_widget() and get_widget_derived()



commit 3d622797bf5169a0d4d7a9337994a00b9bb29a89
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Wed Jun 11 19:14:08 2014 +0200

    Gtk::Builder: Fix ref count in get_widget() and get_widget_derived()
    
    * gtk/src/builder.[hg|ccg]: get_widget() and get_widget_derived() shall not
    add a reference to the fetched widget. Bug #731444.

 gtk/src/builder.ccg |    8 +++-----
 gtk/src/builder.hg  |    3 ++-
 2 files changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/gtk/src/builder.ccg b/gtk/src/builder.ccg
index bad9dd7..59789d3 100644
--- a/gtk/src/builder.ccg
+++ b/gtk/src/builder.ccg
@@ -276,11 +276,9 @@ Gtk::Widget* Builder::get_widget_checked(const Glib::ustring& name, GType type)
     return 0;
   }
 
-  return Glib::wrap (GTK_WIDGET (cobject), true /* take ref */);
+  // Don't take a reference. That's done only in methods that return
+  // a Glib::RefPtr<Something>.
+  return Glib::wrap (GTK_WIDGET (cobject), false /* take ref */);
 }
 
-
-
-
 } // namespace Gtk
-
diff --git a/gtk/src/builder.hg b/gtk/src/builder.hg
index 122bc3f..0b72b9f 100644
--- a/gtk/src/builder.hg
+++ b/gtk/src/builder.hg
@@ -510,7 +510,8 @@ public:
        Glib::RefPtr<Gtk::Builder> refThis(this);
        refThis->reference(); //take a copy.
        widget = new T_Widget(pCWidget, refThis);
-       widget->reference(); //Because gtk_builder_get_object() does not give us a reference.
+       // Don't add reference to widget. That's done only in methods that return
+       // a Glib::RefPtr<Something>.
      }
   }
 


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