mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
If the report already has an id assigned (i.e. restored reports) then
add it to the table using that id. Only generate ids for reports that don't have them yet. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13810 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
1e53468d1e
commit
95995638b2
@ -1,5 +1,10 @@
|
|||||||
2006-04-19 David Hampton <hampton@employees.org>
|
2006-04-19 David Hampton <hampton@employees.org>
|
||||||
|
|
||||||
|
* src/report/report-system/gnc-report.c: If the report already has
|
||||||
|
an id assigned (i.e. restored reports) then add it to the table
|
||||||
|
using that id. Only generate ids for reports that don't have them
|
||||||
|
yet.
|
||||||
|
|
||||||
* src/gnome-utils/gnc-main-window.c: Don't call shutdown directly
|
* src/gnome-utils/gnc-main-window.c: Don't call shutdown directly
|
||||||
from the delete_event handler, but use a periodic idle function
|
from the delete_event handler, but use a periodic idle function
|
||||||
that checks to insure that gnucash isn't saving the data file
|
that checks to insure that gnucash isn't saving the data file
|
||||||
|
@ -69,13 +69,41 @@ SCM gnc_report_find(gint id)
|
|||||||
|
|
||||||
int gnc_report_add(SCM report)
|
int gnc_report_add(SCM report)
|
||||||
{
|
{
|
||||||
gint *key;
|
SCM get_id = scm_c_eval_string("gnc:report-id");
|
||||||
|
SCM value;
|
||||||
|
gint id, *key;
|
||||||
|
|
||||||
gnc_report_init_table();
|
gnc_report_init_table();
|
||||||
|
|
||||||
|
value = scm_call_1(get_id, report);
|
||||||
|
if (SCM_NUMBERP(value)) {
|
||||||
|
id = scm_num2int(value, SCM_ARG1, __FUNCTION__);
|
||||||
|
if (!g_hash_table_lookup(reports, &id)) {
|
||||||
key = g_new(gint, 1);
|
key = g_new(gint, 1);
|
||||||
*key = report_next_serial_id++;
|
*key = id;
|
||||||
g_hash_table_insert(reports, key, (gpointer)report);
|
g_hash_table_insert(reports, key, (gpointer)report);
|
||||||
scm_gc_protect_object(report);
|
scm_gc_protect_object(report);
|
||||||
return *key;
|
return id;
|
||||||
|
}
|
||||||
|
g_warning("Report specified id of %d is already is use. "
|
||||||
|
"Using generated id.", id);
|
||||||
|
}
|
||||||
|
|
||||||
|
id = report_next_serial_id++;
|
||||||
|
while (id < G_MAXINT) {
|
||||||
|
if (!g_hash_table_lookup(reports, &id)) {
|
||||||
|
key = g_new(gint, 1);
|
||||||
|
*key = id;
|
||||||
|
g_hash_table_insert(reports, key, (gpointer)report);
|
||||||
|
scm_gc_protect_object(report);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
id = report_next_serial_id++;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_warning("Unable to add report to table. %d reports in use.", G_MAXINT);
|
||||||
|
report_next_serial_id = G_MAXINT;
|
||||||
|
return G_MAXINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
Loading…
Reference in New Issue
Block a user