From 3e67c985ec32ef250e8b11dd29c13aad68fb4902 Mon Sep 17 00:00:00 2001 From: compudj Date: Wed, 16 Jun 2004 19:15:11 +0000 Subject: [PATCH] fix bug in iattribute git-svn-id: http://ltt.polymtl.ca/svn@593 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/lttv/lttv/attribute.c | 11 ++++++++++- ltt/branches/poly/lttv/lttv/attribute.h | 1 + ltt/branches/poly/lttv/lttv/iattribute.c | 7 +++++-- ltt/branches/poly/lttv/lttv/iattribute.h | 2 ++ ltt/branches/poly/lttv/lttv/traceset.c | 3 ++- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ltt/branches/poly/lttv/lttv/attribute.c b/ltt/branches/poly/lttv/lttv/attribute.c index 53867930..ff69db25 100644 --- a/ltt/branches/poly/lttv/lttv/attribute.c +++ b/ltt/branches/poly/lttv/lttv/attribute.c @@ -467,12 +467,21 @@ lttv_attribute_read_xml(LttvAttribute *self, FILE *fp) fscanf(fp,""); } +static LttvAttribute * +new_attribute (LttvAttribute *self) +{ + return g_object_new(LTTV_ATTRIBUTE_TYPE, NULL); +} + static void attribute_interface_init (gpointer g_iface, gpointer iface_data) { LttvIAttributeClass *klass = (LttvIAttributeClass *)g_iface; + klass->new_attribute = (LttvIAttribute* (*) (LttvIAttribute *self)) + new_attribute; + klass->get_number = (unsigned int (*) (LttvIAttribute *self)) lttv_attribute_get_number; @@ -524,7 +533,7 @@ static void attribute_class_init (LttvAttributeClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - + gobject_class->finalize = (void (*)(GObject *self))attribute_finalize; } diff --git a/ltt/branches/poly/lttv/lttv/attribute.h b/ltt/branches/poly/lttv/lttv/attribute.h index e721b3bf..784fcdc8 100644 --- a/ltt/branches/poly/lttv/lttv/attribute.h +++ b/ltt/branches/poly/lttv/lttv/attribute.h @@ -44,6 +44,7 @@ struct _LttvAttribute { struct _LttvAttributeClass { GObjectClass parent; + }; GType lttv_attribute_get_type (void); diff --git a/ltt/branches/poly/lttv/lttv/iattribute.c b/ltt/branches/poly/lttv/lttv/iattribute.c index ba17e3a2..4293c828 100644 --- a/ltt/branches/poly/lttv/lttv/iattribute.c +++ b/ltt/branches/poly/lttv/lttv/iattribute.c @@ -174,6 +174,7 @@ gboolean lttv_iattribute_find_by_path(LttvIAttribute *self, char *path, } } + /* Shallow and deep copies */ LttvIAttribute *lttv_iattribute_shallow_copy(LttvIAttribute *self) @@ -190,13 +191,14 @@ LttvIAttribute *lttv_iattribute_shallow_copy(LttvIAttribute *self) int nb_attributes = lttv_iattribute_get_number(self); - copy = LTTV_IATTRIBUTE(g_object_new(G_OBJECT_TYPE(self),NULL)); + copy = LTTV_IATTRIBUTE_GET_CLASS(self)->new_attribute(NULL); for(i = 0 ; i < nb_attributes ; i++) { t = lttv_iattribute_get(self, i, &name, &v); v_copy = lttv_iattribute_add(copy, name, t); lttv_iattribute_copy_value(t, v_copy, v); } + return copy; } LttvIAttribute *lttv_iattribute_deep_copy(LttvIAttribute *self) @@ -213,7 +215,7 @@ LttvIAttribute *lttv_iattribute_deep_copy(LttvIAttribute *self) int nb_attributes = lttv_iattribute_get_number(self); - copy = LTTV_IATTRIBUTE(g_object_new(G_OBJECT_TYPE(self), NULL)); + copy = LTTV_IATTRIBUTE_GET_CLASS(self)->new_attribute(NULL); for(i = 0 ; i < nb_attributes ; i++) { t = lttv_iattribute_get(self, i, &name, &v); @@ -224,6 +226,7 @@ LttvIAttribute *lttv_iattribute_deep_copy(LttvIAttribute *self) } else lttv_iattribute_copy_value(t, v_copy, v); } + return copy; } void lttv_iattribute_copy_value(LttvAttributeType t, LttvAttributeValue dest, diff --git a/ltt/branches/poly/lttv/lttv/iattribute.h b/ltt/branches/poly/lttv/lttv/iattribute.h index 11dccd10..95d1fcf1 100644 --- a/ltt/branches/poly/lttv/lttv/iattribute.h +++ b/ltt/branches/poly/lttv/lttv/iattribute.h @@ -66,6 +66,8 @@ typedef struct _LttvIAttributeClass LttvIAttributeClass; struct _LttvIAttributeClass { GTypeInterface parent; + LttvIAttribute* (*new_attribute) (LttvIAttribute *self); + unsigned int (*get_number) (LttvIAttribute *self); gboolean (*named) (LttvIAttribute *self, gboolean *homogeneous); diff --git a/ltt/branches/poly/lttv/lttv/traceset.c b/ltt/branches/poly/lttv/lttv/traceset.c index 568e6721..0e91c9dc 100644 --- a/ltt/branches/poly/lttv/lttv/traceset.c +++ b/ltt/branches/poly/lttv/lttv/traceset.c @@ -18,6 +18,7 @@ #include +#include #include /* A trace is a sequence of events gathered in the same tracing session. The @@ -88,7 +89,7 @@ LttvTraceset *lttv_traceset_copy(LttvTraceset *s_orig) s->traces, g_ptr_array_index(s_orig->traces, i)); } - s->a = LTTV_ATTRIBUTE(lttv_iattribute_deep_copy(LTTV_IATTRIBUTE(s_orig->a))); + s->a = LTTV_ATTRIBUTE(lttv_iattribute_deep_copy((LttvIAttribute*)s_orig->a)); return s; } -- 2.34.1