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)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Tue, 12 Jul 2011 17:13:51 +0000 (19:13 +0200)
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)

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..59c68ca
--- /dev/null
@@ -0,0 +1,23 @@
+\version "2.15.5"
+
+\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 65784f130f141cfef14926a6b3fdbc142c54c9f6..0168da15003a47a245cd425c48659fc63e2eb72e 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;
@@ -274,6 +276,7 @@ Lyric_combine_music_iterator::process (Moment /* when */)
   if (new_voice)
     set_music_context (new_voice);
 
+  lyrics_found_ = true;
   if (!music_context_)
     return;
 
@@ -328,10 +331,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_)