From 34b7b5d74e1d9ea81f772e9b571ae256af38459a Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Sun, 12 Jul 1998 04:13:02 +0000 Subject: [PATCH] call the base classes' object_init_func for derived objects with the Sun Jul 12 05:59:26 1998 Tim Janik * gtk/gtktypeutils.c (gtk_type_new): call the base classes' object_init_func for derived objects with the object's ->klass field still pointing to the corresponding base class, otherwise overridden class functions could get called with partly-initialized objects. (change from Tero Pulkkinen ). --- ChangeLog | 8 ++++++++ ChangeLog.pre-2-0 | 8 ++++++++ ChangeLog.pre-2-10 | 8 ++++++++ ChangeLog.pre-2-2 | 8 ++++++++ ChangeLog.pre-2-4 | 8 ++++++++ ChangeLog.pre-2-6 | 8 ++++++++ ChangeLog.pre-2-8 | 8 ++++++++ gtk/gtktypeutils.c | 14 +++++++++++--- 8 files changed, 67 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index db0c2a18e2..ed11786289 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sun Jul 12 05:59:26 1998 Tim Janik + + * gtk/gtktypeutils.c (gtk_type_new): call the base classes' + object_init_func for derived objects with the object's ->klass field + still pointing to the corresponding base class, otherwise overridden + class functions could get called with partly-initialized objects. + (change from Tero Pulkkinen ). + Sun Jul 12 02:47:35 1998 Tim Janik * gtk/gtkobject.h: diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index db0c2a18e2..ed11786289 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,11 @@ +Sun Jul 12 05:59:26 1998 Tim Janik + + * gtk/gtktypeutils.c (gtk_type_new): call the base classes' + object_init_func for derived objects with the object's ->klass field + still pointing to the corresponding base class, otherwise overridden + class functions could get called with partly-initialized objects. + (change from Tero Pulkkinen ). + Sun Jul 12 02:47:35 1998 Tim Janik * gtk/gtkobject.h: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index db0c2a18e2..ed11786289 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +Sun Jul 12 05:59:26 1998 Tim Janik + + * gtk/gtktypeutils.c (gtk_type_new): call the base classes' + object_init_func for derived objects with the object's ->klass field + still pointing to the corresponding base class, otherwise overridden + class functions could get called with partly-initialized objects. + (change from Tero Pulkkinen ). + Sun Jul 12 02:47:35 1998 Tim Janik * gtk/gtkobject.h: diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index db0c2a18e2..ed11786289 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,11 @@ +Sun Jul 12 05:59:26 1998 Tim Janik + + * gtk/gtktypeutils.c (gtk_type_new): call the base classes' + object_init_func for derived objects with the object's ->klass field + still pointing to the corresponding base class, otherwise overridden + class functions could get called with partly-initialized objects. + (change from Tero Pulkkinen ). + Sun Jul 12 02:47:35 1998 Tim Janik * gtk/gtkobject.h: diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index db0c2a18e2..ed11786289 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,11 @@ +Sun Jul 12 05:59:26 1998 Tim Janik + + * gtk/gtktypeutils.c (gtk_type_new): call the base classes' + object_init_func for derived objects with the object's ->klass field + still pointing to the corresponding base class, otherwise overridden + class functions could get called with partly-initialized objects. + (change from Tero Pulkkinen ). + Sun Jul 12 02:47:35 1998 Tim Janik * gtk/gtkobject.h: diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index db0c2a18e2..ed11786289 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +Sun Jul 12 05:59:26 1998 Tim Janik + + * gtk/gtktypeutils.c (gtk_type_new): call the base classes' + object_init_func for derived objects with the object's ->klass field + still pointing to the corresponding base class, otherwise overridden + class functions could get called with partly-initialized objects. + (change from Tero Pulkkinen ). + Sun Jul 12 02:47:35 1998 Tim Janik * gtk/gtkobject.h: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index db0c2a18e2..ed11786289 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +Sun Jul 12 05:59:26 1998 Tim Janik + + * gtk/gtktypeutils.c (gtk_type_new): call the base classes' + object_init_func for derived objects with the object's ->klass field + still pointing to the corresponding base class, otherwise overridden + class functions could get called with partly-initialized objects. + (change from Tero Pulkkinen ). + Sun Jul 12 02:47:35 1998 Tim Janik * gtk/gtkobject.h: diff --git a/gtk/gtktypeutils.c b/gtk/gtktypeutils.c index 44f240ef45..64a7af5782 100644 --- a/gtk/gtktypeutils.c +++ b/gtk/gtktypeutils.c @@ -339,18 +339,26 @@ gtk_type_new (GtkType type) } else object = g_malloc0 (node->type_info.object_size); - object->klass = klass; + /* we need to call the base classes' object_init_func for derived + * objects with the object's ->klass field still pointing to the + * corresponding base class, otherwise overridden class functions + * could get called with partly-initialized objects. + */ for (i = node->n_supers; i > 0; i--) { GtkTypeNode *pnode; LOOKUP_TYPE_NODE (pnode, node->supers[i]); if (pnode->type_info.object_init_func) - (* pnode->type_info.object_init_func) (object); + { + object->klass = pnode->klass; + pnode->type_info.object_init_func (object); + } } + object->klass = klass; if (node->type_info.object_init_func) - (* node->type_info.object_init_func) (object); + node->type_info.object_init_func (object); return object; }