[libgda] GdaSet and GdauiSet: added debug info, disabled by default
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] GdaSet and GdauiSet: added debug info, disabled by default
- Date: Wed, 16 May 2012 13:25:35 +0000 (UTC)
commit 6962de5b76f514b6d0621aa21a0023fa12267dd3
Author: Vivien Malerba <malerba gnome-db org>
Date: Wed May 16 15:18:48 2012 +0200
GdaSet and GdauiSet: added debug info, disabled by default
and some corrections
libgda-ui/gdaui-set.c | 83 +++++++++++++++++++++++++++++++++++++++++--------
libgda/gda-set.c | 57 +++++++++++++++++++++++++++++++++
2 files changed, 127 insertions(+), 13 deletions(-)
---
diff --git a/libgda-ui/gdaui-set.c b/libgda-ui/gdaui-set.c
index e2ae486..3addc29 100644
--- a/libgda-ui/gdaui-set.c
+++ b/libgda-ui/gdaui-set.c
@@ -45,7 +45,6 @@ static void update_public_data (GdauiSet *set);
static void compute_shown_columns_index (GdauiSetSource *dsource);
static void compute_ref_columns_index (GdauiSetSource *dsource);
-
struct _GdauiSetPriv
{
GdaSet *set;
@@ -310,13 +309,14 @@ update_public_data (GdauiSet *set)
{
GSList *list, *elist = NULL;
GdaSet *aset = GDA_SET (set->priv->set);
- GHashTable *hash;
+ GHashTable *shash; /* key = GdaSetSource, value = GdauiSetSource */
+ GHashTable *ghash; /* key = GdaSetGroup, value = GdauiSetGroup */
- /* build hash with existing sources */
- hash = g_hash_table_new (NULL, NULL);
+ /* build hash with existing sources in GdauiSet */
+ shash = g_hash_table_new (NULL, NULL);
for (list = set->sources_list; list; list = list->next) {
GdauiSetSource *dsource = (GdauiSetSource*) list->data;
- g_hash_table_insert (hash, dsource->source, list->data);
+ g_hash_table_insert (shash, dsource->source, dsource);
}
/* scan GdaSetSource list */
@@ -324,7 +324,7 @@ update_public_data (GdauiSet *set)
set->sources_list = NULL;
for (list = aset->sources_list; list; list = list->next) {
GdauiSetSource *dsource;
- dsource = g_hash_table_lookup (hash, list->data);
+ dsource = g_hash_table_lookup (shash, list->data);
if (dsource) {
set->sources_list = g_slist_prepend (set->sources_list, dsource);
continue;
@@ -332,16 +332,17 @@ update_public_data (GdauiSet *set)
dsource = g_new0 (GdauiSetSource, 1);
set->sources_list = g_slist_prepend (set->sources_list, dsource);
- g_hash_table_insert (hash, list->data, dsource);
+ g_hash_table_insert (shash, list->data, dsource);
dsource->source = GDA_SET_SOURCE (list->data);
compute_shown_columns_index (dsource);
compute_ref_columns_index (dsource);
}
set->sources_list = g_slist_reverse (set->sources_list);
+
if (elist) {
for (list = elist; list; list = list->next) {
- if (!g_slist_find (set->sources_list, elist->data)) {
+ if (!g_slist_find (set->sources_list, list->data)) {
GdauiSetSource *dsource = (GdauiSetSource*) list->data;
g_free (dsource->shown_cols_index);
g_free (dsource->ref_cols_index);
@@ -352,9 +353,10 @@ update_public_data (GdauiSet *set)
}
/* build hash with existing groups */
+ ghash = g_hash_table_new (NULL, NULL);
for (list = set->groups_list; list; list = list->next) {
GdauiSetGroup *dgroup = (GdauiSetGroup*) list->data;
- g_hash_table_insert (hash, dgroup->group, list->data);
+ g_hash_table_insert (ghash, dgroup->group, dgroup);
}
/* scan GdaSetGroup list */
@@ -362,7 +364,7 @@ update_public_data (GdauiSet *set)
set->groups_list = NULL;
for (list = aset->groups_list; list; list = list->next) {
GdauiSetGroup *dgroup;
- dgroup = g_hash_table_lookup (hash, list->data);
+ dgroup = g_hash_table_lookup (ghash, list->data);
if (dgroup) {
set->groups_list = g_slist_prepend (set->groups_list, dgroup);
continue;
@@ -370,12 +372,13 @@ update_public_data (GdauiSet *set)
dgroup = g_new0 (GdauiSetGroup, 1);
set->groups_list = g_slist_prepend (set->groups_list, dgroup);
dgroup->group = GDA_SET_GROUP (list->data);
- dgroup->source = g_hash_table_lookup (hash, GDA_SET_GROUP (list->data)->nodes_source);
+ dgroup->source = g_hash_table_lookup (shash, dgroup->group->nodes_source);
}
set->groups_list = g_slist_reverse (set->groups_list);
+
if (elist) {
for (list = elist; list; list = list->next) {
- if (!g_slist_find (set->sources_list, elist->data)) {
+ if (!g_slist_find (set->groups_list, list->data)) {
GdauiSetGroup *dgroup = (GdauiSetGroup*) list->data;
g_free (dgroup);
}
@@ -383,7 +386,8 @@ update_public_data (GdauiSet *set)
g_slist_free (elist);
}
- g_hash_table_destroy (hash);
+ g_hash_table_destroy (shash);
+ g_hash_table_destroy (ghash);
}
static void
@@ -524,3 +528,56 @@ _gdaui_set_get_group (GdauiSet *dbset, GdaHolder *holder)
}
return NULL;
}
+
+#ifdef GDA_DEBUG_NO
+static void _gda_set_node_dump (GdaSetNode *node);
+static void set_source_dump (GdauiSetSource *source);
+static void set_group_dump (GdauiSetGroup *group);
+
+static void
+set_source_dump (GdauiSetSource *source)
+{
+ g_print (" GdauiSetSource %p\n", source);
+ if (source) {
+ gint i;
+ g_print (" - GdaSetSource: %p\n", source->source);
+ for (i = 0; i < source->shown_n_cols; i++)
+ g_print (" - shown_cols_index [%d]: %d\n", i, source->shown_cols_index[i]);
+ for (i = 0; i < source->ref_n_cols; i++)
+ g_print (" - ref_cols_index [%d]: %d\n", i, source->ref_cols_index[i]);
+ }
+}
+
+static void
+set_group_dump (GdauiSetGroup *group)
+{
+ g_print (" GdauiSetGroup %p\n", group);
+ if (group) {
+ g_print (" - GdaSetGroup: %p\n", group->group);
+ if (group->group->nodes)
+ g_slist_foreach (group->group->nodes, (GFunc) _gda_set_node_dump, NULL);
+ else
+ g_print (" ERROR: group has no node!\n");
+ g_print (" - GdauiSetSource: %p\n", group->source);
+ }
+}
+
+static void
+_gda_set_node_dump (GdaSetNode *node)
+{
+ g_print (" - GdaSetNode: %p\n", node);
+ g_print (" - holder: %p (%s)\n", node->holder, node->holder ? gda_holder_get_id (node->holder) : "ERROR : no GdaHolder!");
+ g_print (" - source_model: %p\n", node->source_model);
+ g_print (" - source_column: %d\n", node->source_column);
+}
+
+static void
+_gdaui_set_dump (GdauiSet *set)
+{
+ g_print ("=== GdauiSet %p ===\n", set);
+ gda_set_dump (set->priv->set);
+ g_slist_foreach (set->sources_list, (GFunc) set_source_dump, NULL);
+ g_slist_foreach (set->groups_list, (GFunc) set_group_dump, NULL);
+ g_print ("=== GdauiSet %p END ===\n", set);
+}
+#endif
diff --git a/libgda/gda-set.c b/libgda/gda-set.c
index 027dd13..a56146e 100644
--- a/libgda/gda-set.c
+++ b/libgda/gda-set.c
@@ -1730,3 +1730,60 @@ gda_set_replace_source_model (GdaSet *set, GdaSetSource *source, GdaDataModel *m
g_print ("<< 'SOURCE_MODEL_CHANGED' from %s\n", __FUNCTION__);
#endif
}
+
+#ifdef GDA_DEBUG_NO
+static void holder_dump (GdaHolder *holder);
+static void set_node_dump (GdaSetNode *node);
+static void set_source_dump (GdaSetSource *source);
+static void set_group_dump (GdaSetGroup *group);
+
+static void
+holder_dump (GdaHolder *holder)
+{
+ g_print (" GdaHolder %p (%s)\n", holder, holder ? gda_holder_get_id (holder) : "---");
+}
+
+static void
+set_source_dump (GdaSetSource *source)
+{
+ g_print (" GdaSetSource %p\n", source);
+ if (source) {
+ g_print (" - data_model: %p\n", source->data_model);
+ GSList *list;
+ for (list = source->nodes; list; list = list->next)
+ g_print (" - node: %p\n", list->data);
+ }
+}
+
+static void
+set_group_dump (GdaSetGroup *group)
+{
+ g_print (" GdaSetGroup %p\n", group);
+ if (group) {
+ GSList *list;
+ for (list = group->nodes; list; list = list->next)
+ g_print (" - node: %p\n", list->data);
+ g_print (" - GdaSetSource: %p\n", group->nodes_source);
+ }
+}
+
+static void
+set_node_dump (GdaSetNode *node)
+{
+ g_print (" GdaSetNode: %p\n", node);
+ g_print (" - holder: %p (%s)\n", node->holder, node->holder ? gda_holder_get_id (node->holder) : "ERROR : no GdaHolder!");
+ g_print (" - source_model: %p\n", node->source_model);
+ g_print (" - source_column: %d\n", node->source_column);
+}
+
+void
+gda_set_dump (GdaSet *set)
+{
+ g_print ("=== GdaSet %p ===\n", set);
+ g_slist_foreach (set->holders, (GFunc) holder_dump, NULL);
+ g_slist_foreach (set->nodes_list, (GFunc) set_node_dump, NULL);
+ g_slist_foreach (set->sources_list, (GFunc) set_source_dump, NULL);
+ g_slist_foreach (set->groups_list, (GFunc) set_group_dump, NULL);
+ g_print ("=== GdaSet %p END ===\n", set);
+}
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]