AUDIT: r15788 - gnucash/trunk/src/gnome-utils - Fix window corruption problems when adding prices to the price
David Hampton
hampton at cvs.gnucash.org
Tue Apr 3 23:57:04 EDT 2007
Author: hampton
Date: 2007-04-03 23:57:04 -0400 (Tue, 03 Apr 2007)
New Revision: 15788
Trac: http://svn.gnucash.org/trac/changeset/15788
Modified:
gnucash/trunk/src/gnome-utils/gnc-tree-model-commodity.c
gnucash/trunk/src/gnome-utils/gnc-tree-model-price.c
gnucash/trunk/src/gnome-utils/gnc-tree-view-price.c
Log:
Fix window corruption problems when adding prices to the price
database. (#376298)
BP
Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-commodity.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-commodity.c 2007-04-04 03:40:14 UTC (rev 15787)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-commodity.c 2007-04-04 03:57:04 UTC (rev 15788)
@@ -1062,29 +1062,28 @@
gnc_tree_model_commodity_path_added (GncTreeModelCommodity *model,
GtkTreeIter *iter)
{
- gnc_commodity_namespace *namespace;
GtkTreePath *path;
- GtkTreeIter ns_iter;
- GList *list;
+ GtkTreeModel *tree_model;
+ GtkTreeIter tmp_iter;
ENTER("model %p, iter (%p)%s", model, iter, iter_to_string(iter));
+ tree_model = GTK_TREE_MODEL(model);
- if (iter->user_data == ITER_IS_COMMODITY) {
- /* Reach out and touch the namespace first */
- gnc_tree_model_commodity_iter_parent (GTK_TREE_MODEL(model), &ns_iter, iter);
- namespace = gnc_tree_model_commodity_get_namespace (model, &ns_iter);
- list = gnc_commodity_namespace_get_commodity_list(namespace);
- if (g_list_length(list) == 1) {
- path = gnc_tree_model_commodity_get_path (GTK_TREE_MODEL(model), &ns_iter);
- gtk_tree_model_row_changed(GTK_TREE_MODEL(model), path, &ns_iter);
- gtk_tree_model_row_has_child_toggled(GTK_TREE_MODEL(model), path, &ns_iter);
- gtk_tree_path_free(path);
- }
+ /* For either namespace or commodity */
+ path = gnc_tree_model_commodity_get_path(tree_model, iter);
+ gtk_tree_model_row_inserted(tree_model, path, iter);
+
+ /* */
+ gtk_tree_path_up(path);
+ while (gtk_tree_path_get_depth(path) != 0) {
+ if (gtk_tree_model_get_iter(tree_model, &tmp_iter, path)) {
+ gtk_tree_model_row_changed(tree_model, path, &tmp_iter);
+ if (gtk_tree_model_iter_n_children(tree_model, &tmp_iter) == 1) {
+ gtk_tree_model_row_has_child_toggled(tree_model, path, &tmp_iter);
+ }
+ }
+ gtk_tree_path_up(path);
}
-
- /* Now for either namespace or commodity */
- path = gnc_tree_model_commodity_get_path (GTK_TREE_MODEL(model), iter);
- gtk_tree_model_row_inserted (GTK_TREE_MODEL(model), path, iter);
gtk_tree_path_free(path);
do {
@@ -1110,13 +1109,16 @@
*/
static void
gnc_tree_model_commodity_path_deleted (GncTreeModelCommodity *model,
- GtkTreePath *path)
+ GtkTreePath *path_in)
{
gnc_commodity_namespace *namespace;
+ GtkTreePath *path;
GtkTreeIter iter;
GList *list;
gint depth;
+ gboolean del_row = TRUE;
+ path = gtk_tree_path_copy(path_in);
debug_path(ENTER, path);
depth = gtk_tree_path_get_depth(path);
@@ -1134,11 +1136,18 @@
list = gnc_commodity_namespace_get_commodity_list(namespace);
if (g_list_length(list) == 0) {
gtk_tree_model_row_has_child_toggled(GTK_TREE_MODEL(model), path, &iter);
+ del_row = FALSE;
}
}
}
}
+ gtk_tree_path_free(path);
+ /* Delete the row, if it hasn't already been deleted by an update of
+ * the parent row. */
+ if (del_row)
+ gtk_tree_model_row_deleted (GTK_TREE_MODEL(model), path_in);
+
do {
model->stamp++;
} while (model->stamp == 0);
@@ -1173,7 +1182,6 @@
data = iter->data;
pending_removals = g_slist_delete_link (pending_removals, iter);
- gtk_tree_model_row_deleted (GTK_TREE_MODEL(data->model), data->path);
gnc_tree_model_commodity_path_deleted (data->model, data->path);
gtk_tree_path_free(data->path);
g_free(data);
Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-price.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-price.c 2007-04-04 03:40:14 UTC (rev 15787)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-price.c 2007-04-04 03:57:04 UTC (rev 15788)
@@ -1325,28 +1325,28 @@
gnc_tree_model_price_path_added (GncTreeModelPrice *model,
GtkTreeIter *iter)
{
- GtkTreePath *path, *tmp_path;
+ GtkTreePath *path;
+ GtkTreeModel *tree_model;
GtkTreeIter tmp_iter;
- gint *indices;
- gint depth, i;
ENTER("model %p, iter (%p)%s", model, iter, iter_to_string(model, iter));
- path = gnc_tree_model_price_get_path (GTK_TREE_MODEL(model), iter);
+ tree_model = GTK_TREE_MODEL(model);
+ path = gnc_tree_model_price_get_path (tree_model, iter);
- /* Tag all the parent nodes as changed. */
- depth = gtk_tree_path_get_depth (path);
- indices = gtk_tree_path_get_indices (path);
- tmp_path = gtk_tree_path_new();
- for (i = 0; i <= depth - 1; i++) {
- gtk_tree_path_append_index (tmp_path, indices[i]);
- gnc_tree_model_price_get_iter (GTK_TREE_MODEL(model), &tmp_iter, tmp_path);
- gtk_tree_model_row_changed(GTK_TREE_MODEL(model), tmp_path, &tmp_iter);
- gtk_tree_model_row_has_child_toggled(GTK_TREE_MODEL(model), tmp_path, &tmp_iter);
+ /* Tag the new item as inserted. */
+ gtk_tree_model_row_inserted (tree_model, path, iter);
+
+ /* */
+ gtk_tree_path_up(path);
+ while (gtk_tree_path_get_depth(path) != 0) {
+ if (gtk_tree_model_get_iter(tree_model, &tmp_iter, path)) {
+ gtk_tree_model_row_changed(tree_model, path, &tmp_iter);
+ if (gtk_tree_model_iter_n_children(tree_model, &tmp_iter) == 1) {
+ gtk_tree_model_row_has_child_toggled(tree_model, path, &tmp_iter);
+ }
+ }
+ gtk_tree_path_up(path);
}
- gtk_tree_path_free(tmp_path);
-
- /* Now tag the new item as inserted. */
- gtk_tree_model_row_inserted (GTK_TREE_MODEL(model), path, iter);
gtk_tree_path_free(path);
do {
Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-price.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-price.c 2007-04-04 03:40:14 UTC (rev 15787)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-price.c 2007-04-04 03:57:04 UTC (rev 15788)
@@ -746,7 +746,11 @@
gnc_tree_view_price_filter_destroy);
/* Whack any existing levels. The top two levels have been created
- * before this routine can be called. */
+ * before this routine can be called. Unfortunately, if the just
+ * applied filter filters out all the nodes in the tree, the gtk
+ * code throws a critical error. This occurs when there are no
+ * prices in the price database. Once the very first price has been
+ * added this error message goes away. */
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
LEAVE(" ");
}
More information about the gnucash-changes
mailing list