[Gnucash-changes] Store the book as part of the model private data.
David Hampton
hampton at cvs.gnucash.org
Fri May 20 23:38:24 EDT 2005
Log Message:
-----------
Store the book as part of the model private data. In the event
handler for the model, ensure that events are for accounts that
are in the model.
Tags:
----
gnucash-gnome2-dev
Modified Files:
--------------
gnucash/src/gnome-utils:
gnc-tree-model-account.c
Revision Data
-------------
Index: gnc-tree-model-account.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-tree-model-account.c,v
retrieving revision 1.1.2.15
retrieving revision 1.1.2.16
diff -Lsrc/gnome-utils/gnc-tree-model-account.c -Lsrc/gnome-utils/gnc-tree-model-account.c -u -r1.1.2.15 -r1.1.2.16
--- src/gnome-utils/gnc-tree-model-account.c
+++ src/gnome-utils/gnc-tree-model-account.c
@@ -92,6 +92,7 @@
struct GncTreeModelAccountPrivate
{
+ QofBook *book;
AccountGroup *root;
Account *toplevel;
gint event_handler_id;
@@ -188,6 +189,7 @@
}
model->priv = g_new0 (GncTreeModelAccountPrivate, 1);
+ model->priv->book = NULL;
model->priv->root = NULL;
model->priv->toplevel = NULL;
@@ -208,6 +210,7 @@
model = GNC_TREE_MODEL_ACCOUNT (object);
active_models = g_list_remove (active_models, model);
+ model->priv->book = NULL;
g_free (model->priv);
if (G_OBJECT_CLASS (parent_class)->finalize)
@@ -261,12 +264,13 @@
NULL);
priv = model->priv;
+ priv->book = gnc_get_current_book();
priv->root = group;
{
Account *account;
- account = xaccMallocAccount(gnc_get_current_book());
+ account = xaccMallocAccount(priv->book);
gnc_tree_model_account_set_toplevel (model, account);
}
@@ -1424,9 +1428,11 @@
model = (GncTreeModelAccount *)user_data;
/* Get the account.*/
- /* DRH - Put the book in the model private data so this code
- * supports multiple simultaneous books. */
- account = xaccAccountLookup (entity, gnc_get_current_book ());
+ account = xaccAccountLookup (entity, model->priv->book);
+ if (!account) {
+ LEAVE("account not in this model's book");
+ return;
+ }
account_name = xaccAccountGetName(account);
switch (event_type) {
More information about the gnucash-changes
mailing list