r15958 - gnucash/branches/2.0 - Fix window corruption problems when adding prices to the price
Derek Atkins
warlord at cvs.gnucash.org
Sat Apr 21 15:18:08 EDT 2007
Author: warlord
Date: 2007-04-21 15:18:05 -0400 (Sat, 21 Apr 2007)
New Revision: 15958
Trac: http://svn.gnucash.org/trac/changeset/15958
Modified:
gnucash/branches/2.0/
gnucash/branches/2.0/ChangeLog
gnucash/branches/2.0/src/gnome-utils/gnc-tree-model-commodity.c
gnucash/branches/2.0/src/gnome-utils/gnc-tree-model-price.c
gnucash/branches/2.0/src/gnome-utils/gnc-tree-view-price.c
Log:
Fix window corruption problems when adding prices to the price
database. (#376298)
Merge from r15788
Property changes on: gnucash/branches/2.0
___________________________________________________________________
Name: svk:merge
- 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/2.0:697
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/2.0:14579
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:13282
+ 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/2.0:697
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/2.0:14580
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:13282
Modified: gnucash/branches/2.0/ChangeLog
===================================================================
--- gnucash/branches/2.0/ChangeLog 2007-04-21 19:17:54 UTC (rev 15957)
+++ gnucash/branches/2.0/ChangeLog 2007-04-21 19:18:05 UTC (rev 15958)
@@ -1,3 +1,8 @@
+2007-04-21 David Hampton <hampton at employees.org>
+
+ * Fix window corruption problems when adding prices to the price
+ database. (#376298)
+
2007-04-21 Andreas Köhler <andi5.py at gmx.net>
* Remove viewport/hbox from account scrolls in transfer dialog.
Modified: gnucash/branches/2.0/src/gnome-utils/gnc-tree-model-commodity.c
===================================================================
--- gnucash/branches/2.0/src/gnome-utils/gnc-tree-model-commodity.c 2007-04-21 19:17:54 UTC (rev 15957)
+++ gnucash/branches/2.0/src/gnome-utils/gnc-tree-model-commodity.c 2007-04-21 19:18:05 UTC (rev 15958)
@@ -1045,29 +1045,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 {
@@ -1093,13 +1092,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);
@@ -1117,11 +1119,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);
@@ -1156,7 +1165,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/branches/2.0/src/gnome-utils/gnc-tree-model-price.c
===================================================================
--- gnucash/branches/2.0/src/gnome-utils/gnc-tree-model-price.c 2007-04-21 19:17:54 UTC (rev 15957)
+++ gnucash/branches/2.0/src/gnome-utils/gnc-tree-model-price.c 2007-04-21 19:18:05 UTC (rev 15958)
@@ -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/branches/2.0/src/gnome-utils/gnc-tree-view-price.c
===================================================================
--- gnucash/branches/2.0/src/gnome-utils/gnc-tree-view-price.c 2007-04-21 19:17:54 UTC (rev 15957)
+++ gnucash/branches/2.0/src/gnome-utils/gnc-tree-view-price.c 2007-04-21 19:18:05 UTC (rev 15958)
@@ -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