mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix window corruption problems when adding prices to the price
database. (#376298) BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15788 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
3a612f804f
commit
b4ca2231db
@ -1062,29 +1062,28 @@ static void
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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_up(path);
|
||||
}
|
||||
gtk_tree_path_free(path);
|
||||
|
||||
do {
|
||||
@ -1110,13 +1109,16 @@ gnc_tree_model_commodity_path_added (GncTreeModelCommodity *model,
|
||||
*/
|
||||
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,10 +1136,17 @@ gnc_tree_model_commodity_path_deleted (GncTreeModelCommodity *model,
|
||||
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++;
|
||||
@ -1173,7 +1182,6 @@ gnc_tree_model_commodity_do_deletions (gpointer unused)
|
||||
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);
|
||||
|
@ -1325,28 +1325,28 @@ static void
|
||||
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 {
|
||||
|
@ -746,7 +746,11 @@ gnc_tree_view_price_set_filter (GncTreeViewPrice *view,
|
||||
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(" ");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user