--- /dev/null
+\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 { }
+>>
DECLARE_LISTENER (check_new_context);
bool music_found_;
+ bool lyrics_found_;
Context *lyrics_context_;
Context *music_context_;
SCM lyricsto_voice_name_;
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;
if (new_voice)
set_music_context (new_voice);
+ lyrics_found_ = true;
if (!music_context_)
return;
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_)