[gtkmm] Bin, Container::remove(): Restore the floating ref of a managed widget.
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Bin, Container::remove(): Restore the floating ref of a managed widget.
- Date: Tue, 13 Nov 2012 10:11:21 +0000 (UTC)
commit 3c5ff2efc3141cf85eda37081d525ae80f353614
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Tue Nov 13 10:33:24 2012 +0100
Bin, Container::remove(): Restore the floating ref of a managed widget.
* gtk/src/bin.ccg:
* gtk/src/container.ccg: If the removed widget is managed, make the added
ref count floating, avoiding excessive ref counts on widgets that are
repeatedly added and removed. Bug #685739.
ChangeLog | 9 +++++++++
gtk/src/bin.ccg | 10 ++++++----
gtk/src/container.ccg | 10 ++++++----
3 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3dae611..b73dd01 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-11-13 Kjell Ahlstedt <kjell ahlstedt bredband net>
+
+ Bin, Container::remove(): Restore the floating ref of a managed widget.
+
+ * gtk/src/bin.ccg:
+ * gtk/src/container.ccg: If the removed widget is managed, make the added
+ ref count floating, avoiding excessive ref counts on widgets that are
+ repeatedly added and removed. Bug #685739.
+
3.6.0:
2012-10-21 Murray Cumming <murrayc murrayc com>
diff --git a/gtk/src/bin.ccg b/gtk/src/bin.ccg
index e93366f..114348b 100644
--- a/gtk/src/bin.ccg
+++ b/gtk/src/bin.ccg
@@ -34,13 +34,15 @@ Bin::remove()
{
Gtk::Widget* cppChild = Glib::wrap(child);
- //If this is a managed widget,
- //then do an extra ref so that it will
- //not be destroyed when adding to another container
- //This should leave it in much the same state as when it was instantiated,
+ //If this is a managed widget, then do an extra ref so that it will not be
+ //destroyed when it is removed, and restore the floating state of the ref.
+ //This should leave it in the same state as when it was instantiated,
//before being added to the first container.
if(cppChild->is_managed_())
+ {
cppChild->reference();
+ g_object_force_floating(static_cast<Glib::Object*>(cppChild)->gobj());
+ }
gtk_container_remove(Container::gobj(), cppChild->gobj());
}
diff --git a/gtk/src/container.ccg b/gtk/src/container.ccg
index 1428d5f..70462ca 100644
--- a/gtk/src/container.ccg
+++ b/gtk/src/container.ccg
@@ -214,13 +214,15 @@ void Container::show_all_children(bool recursive)
void Container::remove(Widget& widget)
{
- //If this is a managed widget,
- //then do an extra ref so that it will
- //not be destroyed when adding to another container
- //This should leave it in much the same state as when it was instantiated,
+ //If this is a managed widget, then do an extra ref so that it will not be
+ //destroyed when it is removed, and restore the floating state of the ref.
+ //This should leave it in the same state as when it was instantiated,
//before being added to the first container.
if(widget.is_managed_())
+ {
widget.reference();
+ g_object_force_floating(static_cast<Glib::Object&>(widget).gobj());
+ }
gtk_container_remove(gobj(), widget.gobj());
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]