mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix bug 586901: Price editor creates price before all information available
When creating a new price, don't create the price when the dialog is opened. Instead, create it in the gui_to_price() routine if no price has been created yet. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18174 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
1ed10b6532
commit
14058ec397
@ -60,6 +60,7 @@ typedef struct
|
|||||||
QofSession *session;
|
QofSession *session;
|
||||||
QofBook *book;
|
QofBook *book;
|
||||||
GNCPriceDB *price_db;
|
GNCPriceDB *price_db;
|
||||||
|
GNCPriceEditType type;
|
||||||
|
|
||||||
GtkWidget * namespace_cbe;
|
GtkWidget * namespace_cbe;
|
||||||
GtkWidget * commodity_cbe;
|
GtkWidget * commodity_cbe;
|
||||||
@ -189,9 +190,6 @@ gui_to_price (PriceEditDialog *pedit_dialog)
|
|||||||
gnc_numeric value;
|
gnc_numeric value;
|
||||||
Timespec date;
|
Timespec date;
|
||||||
|
|
||||||
if (!pedit_dialog->price)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
namespace = gnc_ui_namespace_picker_ns (pedit_dialog->namespace_cbe);
|
namespace = gnc_ui_namespace_picker_ns (pedit_dialog->namespace_cbe);
|
||||||
fullname = gtk_combo_box_get_active_text(GTK_COMBO_BOX(pedit_dialog->commodity_cbe));
|
fullname = gtk_combo_box_get_active_text(GTK_COMBO_BOX(pedit_dialog->commodity_cbe));
|
||||||
commodity = gnc_commodity_table_find_full(gnc_get_current_commodities(), namespace, fullname);
|
commodity = gnc_commodity_table_find_full(gnc_get_current_commodities(), namespace, fullname);
|
||||||
@ -217,6 +215,8 @@ gui_to_price (PriceEditDialog *pedit_dialog)
|
|||||||
value = gnc_amount_edit_get_amount
|
value = gnc_amount_edit_get_amount
|
||||||
(GNC_AMOUNT_EDIT (pedit_dialog->price_edit));
|
(GNC_AMOUNT_EDIT (pedit_dialog->price_edit));
|
||||||
|
|
||||||
|
if (!pedit_dialog->price)
|
||||||
|
pedit_dialog->price = gnc_price_create (pedit_dialog->book);
|
||||||
gnc_price_begin_edit (pedit_dialog->price);
|
gnc_price_begin_edit (pedit_dialog->price);
|
||||||
gnc_price_set_commodity (pedit_dialog->price, commodity);
|
gnc_price_set_commodity (pedit_dialog->price, commodity);
|
||||||
gnc_price_set_currency (pedit_dialog->price, currency);
|
gnc_price_set_currency (pedit_dialog->price, currency);
|
||||||
@ -507,15 +507,16 @@ gnc_price_edit_dialog (GtkWidget * parent,
|
|||||||
pedit_dialog = g_new0 (PriceEditDialog, 1);
|
pedit_dialog = g_new0 (PriceEditDialog, 1);
|
||||||
gnc_price_pedit_dialog_create (parent, pedit_dialog, session);
|
gnc_price_pedit_dialog_create (parent, pedit_dialog, session);
|
||||||
gnc_restore_window_size(GCONF_SECTION, GTK_WINDOW(pedit_dialog->dialog));
|
gnc_restore_window_size(GCONF_SECTION, GTK_WINDOW(pedit_dialog->dialog));
|
||||||
|
pedit_dialog->type = type;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case GNC_PRICE_NEW:
|
case GNC_PRICE_NEW:
|
||||||
if (price) {
|
if (price) {
|
||||||
price = gnc_price_clone(price, pedit_dialog->book);
|
price = gnc_price_clone(price, pedit_dialog->book);
|
||||||
} else {
|
// } else {
|
||||||
price = gnc_price_create (pedit_dialog->book);
|
// price = gnc_price_create (pedit_dialog->book);
|
||||||
}
|
|
||||||
gnc_price_set_source (price, DIALOG_PRICE_EDIT_SOURCE);
|
gnc_price_set_source (price, DIALOG_PRICE_EDIT_SOURCE);
|
||||||
|
}
|
||||||
|
|
||||||
pedit_dialog->new = TRUE;
|
pedit_dialog->new = TRUE;
|
||||||
/* New price will only have one ref, this dialog. */
|
/* New price will only have one ref, this dialog. */
|
||||||
|
Loading…
Reference in New Issue
Block a user