On Wed, May 27, 2009 at 6:04 PM, Patrick McCarty <pnor...@gmail.com> wrote:
> Hello,
>
> This patch fixes a crash that occurs when the specified backend does
> not have an output-preview-framework (used for -dpreview).
>
> I also added a similar check for output-framework just in case a user
> tries to add a new backend, but forgets to add output-framework.

Attached is a revised patch.

Thanks,
Patrick
From 0f8d4e89bb660597344007433fb57b809ae0d2cf 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..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

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

Reply via email to