lilypond-devel
[Top][All Lists]
Advanced

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

Fix 1382 (issue3100041)


From: Carl . D . Sorensen
Subject: Fix 1382 (issue3100041)
Date: Sun, 14 Nov 2010 00:49:38 +0000

Reviewers: carl.d.sorensen_gmail.com,

Message:
Here's a fix for Issue 1382.  It sets the staff position to zero if
staff space is zero, which is a consistent outcome -- all the staff
lines are in the same position so zero works.

Please review.

Thanks,

Carl


Description:
Fix 1382

Please review this at http://codereview.appspot.com/3100041/

Affected files:
  A input/regression/zero_staff_space.ly
  M lily/staff-symbol-referencer.cc


Index: input/regression/zero_staff_space.ly
diff --git a/input/regression/zero_staff_space.ly b/input/regression/zero_staff_space.ly
new file mode 100644
index 0000000000000000000000000000000000000000..ecff185b75c75342ced2421821c7a560844ef8b6
--- /dev/null
+++ b/input/regression/zero_staff_space.ly
@@ -0,0 +1,18 @@
+
+\version "2.13.39"
+\header{
+
+  texidoc="
+Setting staff-space to 0 does not cause a segmentation fault.
+"
+
+}
+
+\new Staff \with {
+  \override StaffSymbol #'staff-space = #0.0
+  }
+  \relative c' {
+    c1
+  }
+}
+
Index: lily/staff-symbol-referencer.cc
diff --git a/lily/staff-symbol-referencer.cc b/lily/staff-symbol-referencer.cc index bec8c8001f9d01ad741365808337c248a953ee94..d7a803a90ee50dc8a9ef718affa7139caadb8412 100644
--- a/lily/staff-symbol-referencer.cc
+++ b/lily/staff-symbol-referencer.cc
@@ -21,8 +21,10 @@

 #include "staff-symbol.hh"
 #include "grob.hh"
+#include "international.hh"
 #include "output-def.hh"
 #include "libc-extension.hh"
+#include "warn.hh"

 int
 Staff_symbol_referencer::line_count (Grob *me)
@@ -82,8 +84,13 @@ Staff_symbol_referencer::get_position (Grob *me)
     {
       Real y = me->relative_coordinate (c, Y_AXIS)
        - st->relative_coordinate (c, Y_AXIS);
-
-      p += 2.0 * y / Staff_symbol::staff_space (st);
+      Real denom = Staff_symbol::staff_space (st);
+      if (denom == 0)
+        {
+ st->warning (_ ("staff-space is 0, setting staff-position to 0"));
+          return p;
+        }
+      p = 2.0 * y / denom;
       return p;
     }
   else if (!st)
@@ -153,7 +160,7 @@ Staff_symbol_referencer::set_position (Grob *me, Real p)
       oldpos = get_position (me);
     }

-
+
   Real ss = Staff_symbol_referencer::staff_space (me);
   me->translate_axis ((p  - oldpos) * ss * 0.5, Y_AXIS);
 }





reply via email to

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