[Gnucash-changes] r13081 - gnucash/trunk/src/gnome - Fix a crash when manipulating commodities before crating the first

David Hampton hampton at cvs.gnucash.org
Thu Feb 2 19:28:17 EST 2006


Author: hampton
Date: 2006-02-02 19:28:16 -0500 (Thu, 02 Feb 2006)
New Revision: 13081
Trac: http://svn.gnucash.org/trac/changeset/13081

Modified:
   gnucash/trunk/src/gnome/dialog-commodities.c
Log:
Fix a crash when manipulating commodities before crating the first
account.


Modified: gnucash/trunk/src/gnome/dialog-commodities.c
===================================================================
--- gnucash/trunk/src/gnome/dialog-commodities.c	2006-02-03 00:24:26 UTC (rev 13080)
+++ gnucash/trunk/src/gnome/dialog-commodities.c	2006-02-03 00:28:16 UTC (rev 13081)
@@ -48,6 +48,7 @@
 typedef struct
 {
   GtkWidget * dialog;
+  QofBook *book;
 
   GncTreeViewCommodity * commodity_tree;
   GtkWidget * edit_button;
@@ -88,7 +89,6 @@
 static void
 remove_clicked (CommoditiesDialog *cd)
 {
-  QofBook *book;
   GNCPriceDB *pdb;
   GList *node;
   GList *prices;
@@ -131,9 +131,9 @@
     g_list_free (accounts);
     return;
   }
+  g_list_free (accounts);
 
-  book = xaccGroupGetBook (xaccAccountGetRoot (accounts->data));
-  pdb = gnc_pricedb_get_db (book);
+  pdb = gnc_pricedb_get_db (cd->book);
   prices = gnc_pricedb_get_prices(pdb, commodity, NULL);
   if (prices)
   {
@@ -175,7 +175,6 @@
   }
 
   gnc_price_list_destroy(prices);
-  g_list_free (accounts);
   gnc_gui_refresh_all ();
 }
 
@@ -288,6 +287,7 @@
   dialog = glade_xml_get_widget (xml, "Commodities Dialog");
 
   cd->dialog = dialog;
+  cd->book = gnc_get_current_book();
   cd->show_currencies = gnc_gconf_get_bool(GCONF_SECTION, "include_iso", NULL);
   
   glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, cd);
@@ -303,7 +303,7 @@
   /* commodity tree */
     
     scrolled_window = glade_xml_get_widget (xml, "commodity_list_window");
-    view = gnc_tree_view_commodity_new(gnc_get_current_book (),
+    view = gnc_tree_view_commodity_new(cd->book,
 				       "gconf-section", GCONF_SECTION,
 				       "show-column-menu", TRUE,
 				       NULL);



More information about the gnucash-changes mailing list