From: Reinhold Kainhofer Date: Mon, 16 Nov 2009 17:57:26 +0000 (+0100) Subject: fix 750: No warning for non-found voice in lyrics combine when lyrics are empty X-Git-Tag: release/2.14.2-1~19 X-Git-Url: https://git.donarmstrong.com/lilypond.git?a=commitdiff_plain;h=34b1e6837657a19eed6570e8d3a78dee86fb1c24;p=lilypond.git 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) Update regtest version for backport --- diff --git a/input/regression/lyric-combine-empty-warning.ly b/input/regression/lyric-combine-empty-warning.ly new file mode 100644 index 0000000000..f87a266fc9 --- /dev/null +++ b/input/regression/lyric-combine-empty-warning.ly @@ -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 { } +>> diff --git a/lily/lyric-combine-music-iterator.cc b/lily/lyric-combine-music-iterator.cc index 7487e2f91b..5327ff9ced 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; @@ -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_)