From 0f8d4e89bb660597344007433fb57b809ae0d2cf Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Wed, 27 May 2009 17:40:20 -0700 Subject: [PATCH] Fix crash when output-preview-framework is missing * If -dpreview is used when output-preview-framework does not exist for the given backend, LilyPond crashes. This patch implements checks for both output-framework and output-preview-framework, and issues warnings if they do not exist. Signed-off-by: Patrick McCarty --- lily/paper-book.cc | 44 +++++++++++++++++++++++++++++--------------- 1 files changed, 29 insertions(+), 15 deletions(-) diff --git a/lily/paper-book.cc b/lily/paper-book.cc index 4307bb0..21b0f07 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -9,6 +9,7 @@ #include "paper-book.hh" #include "grob.hh" +#include "international.hh" #include "main.hh" #include "output-def.hh" #include "paper-column.hh" @@ -174,25 +175,38 @@ Paper_book::output (SCM output_channel) if (get_program_option ("print-pages")) { - SCM func = scm_c_module_lookup (mod, "output-framework"); - - func = scm_variable_ref (func); - scm_apply_0 (func, scm_list_n (output_channel, - self_scm (), - scopes, - dump_fields (), - SCM_UNDEFINED)); + SCM framework = ly_module_lookup (mod, ly_symbol2scm ("output-framework")); + + if (framework != SCM_BOOL_F) + { + SCM func = scm_variable_ref (framework); + scm_apply_0 (func, scm_list_n (output_channel, + self_scm (), + scopes, + dump_fields (), + SCM_UNDEFINED)); + } + else + warning (_f ("the `%s' backend does not support -dprint-pages", + get_output_backend_name ())); } if (get_program_option ("preview")) { - SCM func = scm_c_module_lookup (mod, "output-preview-framework"); - func = scm_variable_ref (func); - scm_apply_0 (func, scm_list_n (output_channel, - self_scm (), - scopes, - dump_fields (), - SCM_UNDEFINED)); + SCM framework = ly_module_lookup (mod, ly_symbol2scm ("output-preview-framework")); + + if (framework != SCM_BOOL_F) + { + SCM func = scm_variable_ref (framework); + scm_apply_0 (func, scm_list_n (output_channel, + self_scm (), + scopes, + dump_fields (), + SCM_UNDEFINED)); + } + else + warning (_f ("the `%s' backend does not support -dpreview", + get_output_backend_name ())); } } -- 1.6.3.1