r17175 - gnucash/branches/gda-dev2 - 1) Plug leak of GDate objects
Phil Longstaff
plongstaff at cvs.gnucash.org
Mon May 26 20:52:35 EDT 2008
Author: plongstaff
Date: 2008-05-26 20:52:34 -0400 (Mon, 26 May 2008)
New Revision: 17175
Trac: http://svn.gnucash.org/trac/changeset/17175
Modified:
gnucash/branches/gda-dev2/GDA_STATUS
gnucash/branches/gda-dev2/src/backend/gda/gnc-backend-gda.c
gnucash/branches/gda-dev2/src/backend/gda/gnc-backend-util-gda.c
gnucash/branches/gda-dev2/src/gnc-ui.h
gnucash/branches/gda-dev2/src/gnome/dialog-price-editor.c
Log:
1) Plug leak of GDate objects
2) In gnc_gda_commit_edit(), check if the object being edited is a
PriceDB (which is an engine object but not in the database). If it is,
just mark it clean and return.
3) In dialog-price-editor.c, don't try to set any properties in a new
GNCPrice until they are all available. This prevents a commit of a
price with no commodity.
4) Remove return value from gnc_price_edit_dialog which is never used
5) Update GDA_STATUS
Modified: gnucash/branches/gda-dev2/GDA_STATUS
===================================================================
--- gnucash/branches/gda-dev2/GDA_STATUS 2008-05-25 22:50:06 UTC (rev 17174)
+++ gnucash/branches/gda-dev2/GDA_STATUS 2008-05-27 00:52:34 UTC (rev 17175)
@@ -25,3 +25,7 @@
* Write automated tests
* Write doxygen comment headers
* Don't need a log file
+* Certain dialogs create an object when opened and update it as they go along. This
+can result in trying to save invalid objects:
+ - Price editor (new price has no commodity or currency)
+ - New invoice
Modified: gnucash/branches/gda-dev2/src/backend/gda/gnc-backend-gda.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/gda/gnc-backend-gda.c 2008-05-25 22:50:06 UTC (rev 17174)
+++ gnucash/branches/gda-dev2/src/backend/gda/gnc-backend-gda.c 2008-05-27 00:52:34 UTC (rev 17175)
@@ -740,6 +740,13 @@
return;
}
+ // The engine has a PriceDB object but it isn't in the database
+ if( strcmp( inst->e_type, "PriceDB" ) == 0 ) {
+ qof_instance_mark_clean(inst);
+ qof_book_mark_saved( be->primary_book );
+ return;
+ }
+
ENTER( " " );
DEBUG( "gda_commit_edit(): %s dirty = %d, do_free=%d\n",
@@ -782,6 +789,10 @@
}
}
}
+
+ // Don't let unknown items still mark the book as being dirty
+ qof_instance_mark_clean(inst);
+ qof_book_mark_saved( be->primary_book );
return;
}
if( be->supports_transactions ) {
Modified: gnucash/branches/gda-dev2/src/backend/gda/gnc-backend-util-gda.c
===================================================================
--- gnucash/branches/gda-dev2/src/backend/gda/gnc-backend-util-gda.c 2008-05-25 22:50:06 UTC (rev 17174)
+++ gnucash/branches/gda-dev2/src/backend/gda/gnc-backend-util-gda.c 2008-05-27 00:52:34 UTC (rev 17175)
@@ -930,7 +930,7 @@
sscanf( iso8601_buf, "%d-%d-%d", &y, &m, &d );
g_date_set_dmy( date, d, m, y );
g_value_init( value, G_TYPE_DATE );
- g_value_set_boxed( value, date );
+ g_value_take_boxed( value, date );
}
static void
Modified: gnucash/branches/gda-dev2/src/gnc-ui.h
===================================================================
--- gnucash/branches/gda-dev2/src/gnc-ui.h 2008-05-25 22:50:06 UTC (rev 17174)
+++ gnucash/branches/gda-dev2/src/gnc-ui.h 2008-05-27 00:52:34 UTC (rev 17175)
@@ -111,7 +111,7 @@
GNC_PRICE_NEW,
} GNCPriceEditType;
-GNCPrice* gnc_price_edit_dialog (gncUIWidget parent, QofSession *session,
+void gnc_price_edit_dialog (gncUIWidget parent, QofSession *session,
GNCPrice *price, GNCPriceEditType type);
GNCPrice* gnc_price_edit_by_guid (GtkWidget * parent, const GUID * guid);
void gnc_prices_dialog (gncUIWidget parent);
Modified: gnucash/branches/gda-dev2/src/gnome/dialog-price-editor.c
===================================================================
--- gnucash/branches/gda-dev2/src/gnome/dialog-price-editor.c 2008-05-25 22:50:06 UTC (rev 17174)
+++ gnucash/branches/gda-dev2/src/gnome/dialog-price-editor.c 2008-05-27 00:52:34 UTC (rev 17175)
@@ -121,9 +121,9 @@
gnc_numeric value;
Timespec date;
- if (pedit_dialog->price)
+ commodity = gnc_price_get_commodity (pedit_dialog->price);
+ if (commodity)
{
- commodity = gnc_price_get_commodity (pedit_dialog->price);
currency = gnc_price_get_currency (pedit_dialog->price);
date = gnc_price_get_time (pedit_dialog->price);
source = gnc_price_get_source (pedit_dialog->price);
@@ -132,11 +132,10 @@
}
else
{
- commodity = NULL;
currency = gnc_default_currency ();
date.tv_sec = time (NULL);
date.tv_nsec = 0;
- source = "";
+ source = "user:price-editor";
type = "";
value = gnc_numeric_zero ();
}
@@ -385,22 +384,6 @@
}
static void
-gnc_price_new_price_init (GNCPrice *price)
-{
- Timespec date;
-
- gnc_price_begin_edit (price);
-
- gnc_price_set_source (price, "user:price-editor");
- date.tv_sec = time (NULL);
- date.tv_nsec = 0;
- gnc_price_set_time (price, date);
-
- gnc_price_commit_edit (price);
-
-}
-
-static void
close_handler (gpointer user_data)
{
PriceEditDialog *pedit_dialog = user_data;
@@ -437,7 +420,7 @@
* Args: parent - the parent of the window to be created *
* Return: nothing *
\********************************************************************/
-GNCPrice *
+void
gnc_price_edit_dialog (GtkWidget * parent,
QofSession *session,
GNCPrice * price,
@@ -449,7 +432,7 @@
if ((type == GNC_PRICE_EDIT) &&
(gnc_forall_gui_components (DIALOG_PRICE_EDIT_CM_CLASS,
show_handler, price)))
- return(price);
+ return;
pedit_dialog = g_new0 (PriceEditDialog, 1);
gnc_price_pedit_dialog_create (parent, pedit_dialog, session);
@@ -462,7 +445,7 @@
} else {
price = gnc_price_create (pedit_dialog->book);
}
- gnc_price_new_price_init(price);
+
pedit_dialog->new = TRUE;
/* New price will only have one ref, this dialog. */
break;
@@ -474,16 +457,12 @@
pedit_dialog->price = price;
price_to_gui(pedit_dialog);
-
component_id = gnc_register_gui_component (DIALOG_PRICE_EDIT_CM_CLASS,
refresh_handler, close_handler,
pedit_dialog);
gnc_gui_component_set_session (component_id, pedit_dialog->session);
-
gtk_widget_grab_focus (pedit_dialog->commodity_edit);
-
gtk_widget_show (pedit_dialog->dialog);
- return(price);
}
/********************************************************************\
@@ -504,5 +483,6 @@
if (price == NULL)
return(NULL);
- return(gnc_price_edit_dialog(parent, session, price, GNC_PRICE_EDIT));
+ gnc_price_edit_dialog(parent, session, price, GNC_PRICE_EDIT);
+ return price;
}
More information about the gnucash-changes
mailing list