[gtkmm] Correct base type check in Container_Class::remove_callback()
- From: Daniel Elstner <daniel src gnome org>
- To: svn-commits-list gnome org
- Subject: [gtkmm] Correct base type check in Container_Class::remove_callback()
- Date: Wed, 8 Jul 2009 20:40:00 +0000 (UTC)
commit 4474ebb25f0309bb88e890b118db78beed5261d5
Author: Daniel Elstner <danielk openismus com>
Date: Wed Jul 8 21:43:40 2009 +0200
Correct base type check in Container_Class::remove_callback()
* gtk/src/container.ccg (Gtk::Container_Class::remove_callback):
In order to test for the abstract GtkContainer parent class, actually
compare against the parent type instead of making invalid assumptions
about the derived type. By means of the alternative Glib::ObjectBase
constructor, it is possible to create a custom GObject type different
from the standard one.
ChangeLog | 11 +++++++++++
gtk/src/container.ccg | 23 ++++++++---------------
2 files changed, 19 insertions(+), 15 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 87bbd59..d066597 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-07-08 Daniel Elstner <danielk openismus com>
+
+ Correct base type check in Container_Class::remove_callback()
+
+ * gtk/src/container.ccg (Gtk::Container_Class::remove_callback):
+ In order to test for the abstract GtkContainer parent class, actually
+ compare against the parent type instead of making invalid assumptions
+ about the derived type. By means of the alternative Glib::ObjectBase
+ constructor, it is possible to create a custom GObject type different
+ from the standard one.
+
2008-03-08 Murray Cumming <murrayc murrayc com>
* gtk/src/container.ccg: remove_callback(): When just calling the C
diff --git a/gtk/src/container.ccg b/gtk/src/container.ccg
index 3684856..5bcd683 100644
--- a/gtk/src/container.ccg
+++ b/gtk/src/container.ccg
@@ -162,21 +162,14 @@ void Container_Class::remove_callback(GtkContainer* self, GtkWidget* p0)
}
else
{
- //Call the original underlying C function:
-
- //But don't do this if the GType is just the base GtkContainer
- //(the case when deriving from Gtk::Container)
- //because GtkContainer::remove() then shows a warning that it was not implemented,
- //and that warning is not useful to us in that case.
- if(G_OBJECT_TYPE(self) == Gtk::Container::get_type())
- return;
-
- //Call the original underlying C function:
- BaseClassType *const base = static_cast<BaseClassType*>(
- g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
- );
-
- if(base && base->remove)
+ BaseClassType *const base =
+ static_cast<BaseClassType*>(g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)));
+
+ // Do not try to call the default implementation of the virtual function
+ // GtkContainerClass::remove(), because it unhelpfully informs us that
+ // it isn't implemented. This leaves us with no generic means to check
+ // whether it is implemented.
+ if(base && G_TYPE_FROM_CLASS(base) != GTK_TYPE_CONTAINER && base->remove)
(*base->remove)(self, p0);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]