]> git.donarmstrong.com Git - lilypond.git/commitdiff
fix 750: No warning for non-found voice in lyrics combine when lyrics are empty
authorReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 16 Nov 2009 17:57:26 +0000 (18:57 +0100)
committerCarl Sorensen <c_sorensen@byu.edu>
Wed, 13 Jul 2011 18:45:56 +0000 (12:45 -0600)
Use a bool flag to store whether the Lyrics context was ever really created
(i.e. one moment was processed). If that's not the case, then the lyrics
are empty, and we shouldn't print any warning about non-existing voices
(since we never even tried to find an appropriate voice; and we also don't
need one anyway).

Fixes isse 750 (http://code.google.com/p/lilypond/issues/detail?id=750)

Update regtest version for backport

input/regression/lyric-combine-empty-warning.ly [new file with mode: 0644]
lily/lyric-combine-music-iterator.cc

diff --git a/input/regression/lyric-combine-empty-warning.ly b/input/regression/lyric-combine-empty-warning.ly
new file mode 100644 (file)
index 0000000..f87a266
--- /dev/null
@@ -0,0 +1,23 @@
+\version "2.14.2"
+
+\header {
+
+  texidoc = "If lyrics are assigned to a non-existing voice, a warning should
+be printed.  However, if the lyrics context does not contain any lyrics, then
+no warning should be printed."
+
+}
+
+#(ly:set-option 'warning-as-error #f)
+<<
+  \new Staff
+    \new Voice = "notes" {
+      c1
+    }
+  % This should not give a warning (empty lyrics, existing voice):
+  \new Lyrics \lyricsto "notes" \lyricmode { }
+  % This should give a warning (non-existing voice):
+  \new Lyrics \lyricsto "not-existing-notes" \lyricmode { Test }
+  % This should NOT give a warning (non-existing voice, but also no lyrics):
+  \new Lyrics \lyricsto "not-existing-notes" \lyricmode { }
+>>
index 7487e2f91b2b1ccb5a88591846119fdec6041aef..5327ff9ced501a554bef91887bd11ef04d55357d 100644 (file)
@@ -63,6 +63,7 @@ private:
   DECLARE_LISTENER (check_new_context);
 
   bool music_found_;
+  bool lyrics_found_;
   Context *lyrics_context_;
   Context *music_context_;
   SCM lyricsto_voice_name_;
@@ -76,6 +77,7 @@ private:
 Lyric_combine_music_iterator::Lyric_combine_music_iterator ()
 {
   music_found_ = false;
+  lyrics_found_ = false;
   pending_grace_moment_.set_infinite (1);
   lyric_iter_ = 0;
   music_context_ = 0;
@@ -278,6 +280,7 @@ Lyric_combine_music_iterator::process (Moment /* when */)
   if (new_voice)
     set_music_context (new_voice);
 
+  lyrics_found_ = true;
   if (!music_context_)
     return;
 
@@ -332,10 +335,12 @@ Lyric_combine_music_iterator::do_quit ()
 
       string name;
       if (scm_is_string (voice_name))
-       name = ly_scm2string (voice_name);
-
-      get_music ()->origin ()->warning (_f ("cannot find Voice `%s'",
-                                           name.c_str ()) + "\n");
+        name = ly_scm2string (voice_name);
+      /* Don't print a warning for empty lyrics (in which case we don't try
+         to find the proper voice, so it will not be found) */
+      if (lyrics_found_)
+        get_music ()->origin ()->warning (_f ("cannot find Voice `%s'",
+                                              name.c_str ()) + "\n");
     }
 
   if (lyric_iter_)