fix bug in iattribute
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 16 Jun 2004 19:15:11 +0000 (19:15 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 16 Jun 2004 19:15:11 +0000 (19:15 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@593 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/lttv/attribute.c
ltt/branches/poly/lttv/lttv/attribute.h
ltt/branches/poly/lttv/lttv/iattribute.c
ltt/branches/poly/lttv/lttv/iattribute.h
ltt/branches/poly/lttv/lttv/traceset.c

index 5386793015b3421b2106f336f599197ff1faa371..ff69db2537bb3998ae100ec6772a88fcf723e45c 100644 (file)
@@ -467,12 +467,21 @@ lttv_attribute_read_xml(LttvAttribute *self, FILE *fp)
   fscanf(fp,"</ATTRS>");
 }
 
+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;
 }
 
index e721b3bf3f315b37cd9a639d9a21dbba523044e7..784fcdc80d7f9151083dc1dc300d8cd109227a7f 100644 (file)
@@ -44,6 +44,7 @@ struct _LttvAttribute {
 
 struct _LttvAttributeClass {
   GObjectClass parent;
+
 };
 
 GType lttv_attribute_get_type (void);
index ba17e3a23fd1167f9da632fc0c7a6361a802e367..4293c828806bb29f9a37e7266775a95dea2c6e2e 100644 (file)
@@ -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, 
index 11dccd10ad178af57a5228c63071b7c3478347ce..95d1fcf1e386c6f03ad309613f5873f62587ba1a 100644 (file)
@@ -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);
index 568e67212eb5afb9e54a25a5f2b4169fad66c8f2..0e91c9dcf00ee7000daf34b344d83826430afc9a 100644 (file)
@@ -18,6 +18,7 @@
 
 
 #include <lttv/traceset.h>
+#include <lttv/iattribute.h>
 #include <stdio.h>
 
 /* 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;
 }
 
This page took 0.026882 seconds and 4 git commands to generate.