Gracefully handle errors in report options.

This prevents the whole program from crashing when unrecognized report
   options are used.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13227 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Chris Shoemaker 2006-02-12 02:40:35 +00:00
parent c9bef42eda
commit 0dccf4e0cb

View File

@ -49,6 +49,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h> #include <errno.h>
#include "gfec.h"
#include "gnc-component-manager.h" #include "gnc-component-manager.h"
#include "gnc-engine.h" #include "gnc-engine.h"
#include "gnc-gconf-utils.h" #include "gnc-gconf-utils.h"
@ -1286,17 +1287,25 @@ gnc_plugin_page_report_export_cb( GtkAction *action, GncPluginPageReport *report
return; return;
} }
static void
error_handler(const char *str)
{
g_warning("Report Error: %s", str);
}
static void static void
gnc_plugin_page_report_options_cb( GtkAction *action, GncPluginPageReport *report ) gnc_plugin_page_report_options_cb( GtkAction *action, GncPluginPageReport *report )
{ {
GncPluginPageReportPrivate *priv; GncPluginPageReportPrivate *priv;
SCM start_editor = scm_c_eval_string("gnc:report-edit-options"); SCM start_editor = scm_c_eval_string("gnc:report-edit-options");
SCM result;
priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report); priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report);
if (priv->cur_report == SCM_BOOL_F) if (priv->cur_report == SCM_BOOL_F)
return; return;
if (scm_call_1(start_editor, priv->cur_report) == SCM_BOOL_F) { result = gfec_apply(start_editor, priv->cur_report, error_handler);
if (result == SCM_BOOL_F || result == SCM_UNDEFINED) {
gnc_warning_dialog(GTK_WIDGET(gnc_ui_get_toplevel()), gnc_warning_dialog(GTK_WIDGET(gnc_ui_get_toplevel()),
_("There are no options for this report.")); _("There are no options for this report."));
} }