lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: engraver: continue when trying to create non-existent Grob (issue 54


From: hanwenn
Subject: Re: engraver: continue when trying to create non-existent Grob (issue 547620043 by address@hidden)
Date: Mon, 10 Feb 2020 13:35:30 -0800

Reviewers: dak,

Message:
On 2020/02/10 21:31:46, dak wrote:
>
https://codereview.appspot.com/547620043/diff/545560043/lily/engraver.cc
> File lily/engraver.cc (right):
> 
>
https://codereview.appspot.com/547620043/diff/545560043/lily/engraver.cc#newcode126
> lily/engraver.cc:126: grob = new Item (SCM_EOL);
> Ugh.  How is that going to work?  I am not sure we aren't better off
with a hard
> exit.  Admittedly, a failed assertion makes little sense after a
> programming_error: this should have been a hard error in the first
place.
> 
> What is the use case?

Without this, you get a segfault because we take a cdr of an empty list.


Description:
engraver: continue when trying to create non-existent Grob

Please review this at https://codereview.appspot.com/547620043/

Affected files (+19, -16 lines):
  M lily/engraver.cc


Index: lily/engraver.cc
diff --git a/lily/engraver.cc b/lily/engraver.cc
index 
29e1fb53c3aae1080975e999e0de1661f9824564..347fcb177bca8e680f42d6b59a666e59582ef0a8
 100644
--- a/lily/engraver.cc
+++ b/lily/engraver.cc
@@ -118,23 +118,26 @@ Engraver::internal_make_grob (SCM symbol,
 #endif
 
   SCM props = Grob_property_info (context (), symbol).updated ();
-  if (!scm_is_pair (props)) {
-    programming_error (to_string ("No grob definition found for `%s’.",
-      ly_symbol2string (symbol).c_str ()));
-  };
-
   Grob *grob = 0;
-
-  SCM handle = scm_sloppy_assq (ly_symbol2scm ("meta"), props);
-  SCM klass = scm_cdr (scm_sloppy_assq (ly_symbol2scm ("class"), scm_cdr 
(handle)));
-
-  if (scm_is_eq (klass, ly_symbol2scm ("Item")))
-    grob = new Item (props);
-  else if (scm_is_eq (klass, ly_symbol2scm ("Spanner")))
-    grob = new Spanner (props);
-  else if (scm_is_eq (klass, ly_symbol2scm ("Paper_column")))
-    grob = new Paper_column (props);
-
+  if (!scm_is_pair (props))
+    {
+      programming_error (to_string ("No grob definition found for `%s’.",
+                                    ly_symbol2string (symbol).c_str ()));
+      grob = new Item (SCM_EOL);
+    }
+  else
+    {
+      SCM handle = scm_sloppy_assq (ly_symbol2scm ("meta"), props);
+      SCM klass = scm_cdr (
+          scm_sloppy_assq (ly_symbol2scm ("class"), scm_cdr (handle)));
+
+      if (scm_is_eq (klass, ly_symbol2scm ("Item")))
+        grob = new Item (props);
+      else if (scm_is_eq (klass, ly_symbol2scm ("Spanner")))
+        grob = new Spanner (props);
+      else if (scm_is_eq (klass, ly_symbol2scm ("Paper_column")))
+        grob = new Paper_column (props);
+    }
   assert (grob);
   announce_grob (grob, cause);
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]