From 10267f06f910f763196b391bd2bc664db7a78e0a Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Mon, 16 Nov 2009 18:57:26 +0100 Subject: [PATCH] fix 750: No warning for non-found voice in lyrics combine when lyrics are empty 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) --- .../regression/lyric-combine-empty-warning.ly | 23 +++++++++++++++++++ lily/lyric-combine-music-iterator.cc | 13 +++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 input/regression/lyric-combine-empty-warning.ly diff --git a/input/regression/lyric-combine-empty-warning.ly b/input/regression/lyric-combine-empty-warning.ly new file mode 100644 index 0000000000..59c68ca425 --- /dev/null +++ b/input/regression/lyric-combine-empty-warning.ly @@ -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 { } +>> diff --git a/lily/lyric-combine-music-iterator.cc b/lily/lyric-combine-music-iterator.cc index 65784f130f..0168da1500 100644 --- a/lily/lyric-combine-music-iterator.cc +++ b/lily/lyric-combine-music-iterator.cc @@ -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_) -- 2.39.2