On Thu, May 28, 2009 at 10:46:11PM +0200, Reinhold Kainhofer wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Am Donnerstag, 28. Mai 2009 22:18:23 schrieb Neil Puttock:
> > +   warning (_f ("the `%s' backend does not support -dprint-pages",
> > +                get_output_backend_name ()));
> >
> > +   warning (_f ("the `%s' backend does not support -dpreview",
> > +                get_output_backend_name ()));
> >
> > I'm not sure about these; personally I'd prefer having the important
> > information (the unsupported backend) at the end of the message:
> >
> > "unsupported backend for program option -dpreview: `%s'"
> 
> This way, the explanation "unsupported backend" and the type of backend are 
> very far apart and as such this message is much harder to understand. If you 
> prefer the backend at the end, I would formulate it as:
> 
> Program option -dpreview not supported by backend `%s'.

I like Reinhold's suggestion a little more, so I think we should go
with it.

A new patch with revised warning messages is attached.

Thanks,
Patrick
From 224b0a0f315a3da49ba9147af7b6731db523809e Mon Sep 17 00:00:00 2001
From: Patrick McCarty <pnor...@gmail.com>
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 <pnor...@gmail.com>
---
 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..fd519d5 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 ("program option -dprint-pages not supported by backend 
`%s'",
+                    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 ("program option -dpreview not supported by backend `%s'",
+                    get_output_backend_name ()));
     }
 }
 
-- 
1.6.3.1

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to