From: Neil Puttock Date: Mon, 20 Sep 2010 22:13:02 +0000 (+0100) Subject: Fix #818. X-Git-Tag: release/2.13.34-1~6 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c115eee78ce32dab7ee8b8e9a3f24836ab7f5211;p=lilypond.git Fix #818. Use unsmob_engraver ()/unsmob_performer () instead of explicit casting in translator-group.cc when filtering translators added via \with { } * lily/include/performer.hh, lily/performer.hh add unsmob_performer () * lily/translator-group.cc (filter_engravers/filter_performers): use unsmob_* () instead of dynamic_cast when checking translator is of correct class to remove --- diff --git a/input/regression/filter-translators.ly b/input/regression/filter-translators.ly new file mode 100644 index 0000000000..1c10a223f5 --- /dev/null +++ b/input/regression/filter-translators.ly @@ -0,0 +1,21 @@ +\version "2.13.34" + +\header { + texidoc = "Context modification via @code{\\with} filters translators +of the wrong type: performers for an @code{Engraver_group} and engravers +for a @code{Performer_group}. In this test, the +@code{Instrument_name_engraver} is added to a @code{StaffGroup}, but +does not affect midi output, since it is filtered out." +} + +\score { + \new StaffGroup \with { + \consists "Instrument_name_engraver" + instrumentName = #"StaffGroup" + } + { + a'1 + } + \layout { } + \midi { } +} diff --git a/lily/include/performer.hh b/lily/include/performer.hh index 11a5c32c8a..0b0497e322 100644 --- a/lily/include/performer.hh +++ b/lily/include/performer.hh @@ -40,5 +40,7 @@ protected: virtual void create_audio_elements (); }; +Performer *unsmob_performer (SCM perf); + #endif /* PERFORMER_HH */ diff --git a/lily/performer.cc b/lily/performer.cc index c177f9e975..60a0519d42 100644 --- a/lily/performer.cc +++ b/lily/performer.cc @@ -19,6 +19,7 @@ */ #include "context.hh" +#include "performer.hh" #include "performer-group.hh" #include "warn.hh" @@ -48,3 +49,9 @@ Performer::announce_element (Audio_element_info i) get_daddy_performer ()->announce_element (i); } + +Performer * +unsmob_performer (SCM perf) +{ + return dynamic_cast (unsmob_translator (perf)); +} diff --git a/lily/translator-group.cc b/lily/translator-group.cc index 84a97bf52e..f9812e9798 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -23,11 +23,13 @@ #include "context-def.hh" #include "context.hh" #include "dispatcher.hh" +#include "engraver.hh" #include "engraver-group.hh" #include "international.hh" #include "main.hh" #include "music.hh" #include "output-def.hh" +#include "performer.hh" #include "performer-group.hh" #include "scheme-engraver.hh" #include "scm-hash.hh" @@ -52,7 +54,7 @@ Translator_group::connect_to_context (Context *c) if (context_) { programming_error ("translator group is already connected to context " - + context_->context_name ()); + + context_->context_name ()); } context_ = c; @@ -84,13 +86,22 @@ Translator_group::finalize () { } +/* + Both filter_performers and filter_engravers used to use a direct dynamic_cast + on the unsmobbed translator to be filtered, i.e., + + if (dynamic_cast (unsmob_translator (scm_car (*tail)))) + + but this caused mysterious optimisation issues in several GUB builds. See + issue #818 for the background to this change. +*/ SCM filter_performers (SCM ell) { SCM *tail = ℓ for (SCM p = ell; scm_is_pair (p); p = scm_cdr (p)) { - if (dynamic_cast (unsmob_translator (scm_car (*tail)))) + if (unsmob_performer (scm_car (*tail))) *tail = scm_cdr (*tail); else tail = SCM_CDRLOC (*tail); @@ -104,7 +115,7 @@ filter_engravers (SCM ell) SCM *tail = ℓ for (SCM p = ell; scm_is_pair (p); p = scm_cdr (p)) { - if (dynamic_cast (unsmob_translator (scm_car (*tail)))) + if (unsmob_engraver (scm_car (*tail))) *tail = scm_cdr (*tail); else tail = SCM_CDRLOC (*tail);