From: fred Date: Sun, 24 Mar 2002 20:02:16 +0000 (+0000) Subject: lilypond-0.1.45 X-Git-Tag: release/1.5.59~3616 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f5b5255f243a509e6ed76fe80efa364bcca4f55c;p=lilypond.git lilypond-0.1.45 --- diff --git a/lily/change-iterator.cc b/lily/change-iterator.cc index c6ebf2907f..883e963e9f 100644 --- a/lily/change-iterator.cc +++ b/lily/change-iterator.cc @@ -1,5 +1,5 @@ /* - change-iterator.cc -- implement + change-iterator.cc -- implement Change_iterator source file of the GNU LilyPond music typesetter @@ -9,12 +9,28 @@ #include "change-iterator.hh" #include "translator-group.hh" #include "change-translator.hh" +#include "debug.hh" Change_iterator::Change_iterator (Change_translator *change_l) { change_l_ = change_l; } +void +Change_iterator::error (String reason) +{ + String to_type = change_l_->change_to_type_str_; + String to_id = change_l_->change_to_id_str_; + + String warn1 = + _ ("Can't change ") + to_type + + _(" to ") + "`" + to_id + "\': " + reason; + String warn2= "Change_iterator::process_and_next (): " + report_to_l ()->type_str_ + " = `" + + report_to_l ()->id_str_ + "\': "; + warning (warn2); + change_l_->warning (warn1); +} + /* move to construct_children ? */ @@ -23,20 +39,42 @@ Change_iterator::process_and_next (Moment m) { Translator_group * current = report_to_l (); Translator_group * last = 0; - while (current && current->type_str_ != change_l_->change_to_type_str_) + + String to_type = change_l_->change_to_type_str_; + String to_id = change_l_->change_to_id_str_; + + /* find the type of translator that we're changing. + + If \translator Staff = bass, then look for Staff = * + */ + while (current && current->type_str_ != to_type) { last = current; current = current->daddy_trans_l_; } - if (current) - { - Translator_group * dest = - report_to_l ()->find_create_translator_l (change_l_->change_to_type_str_, - change_l_->change_to_id_str_); - current->remove_translator_p (last); - dest->add (last); - } + + if (current) + if (last) + { + Translator_group * dest = + report_to_l ()->find_create_translator_l (to_type, to_id); + current->remove_translator_p (last); + dest->add (last); + } + else + { + + /* + We could change the current translator's id, but that would make + errors hard to catch + + last->translator_id_str_ = change_l_->change_to_id_str_; + */ + error ("I'm one myself"); + } + else + error ("None of these in my family."); Music_iterator::process_and_next (m); } diff --git a/lily/translator-group.cc b/lily/translator-group.cc index dfd31f8469..8918a48543 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -215,6 +215,8 @@ Translator_group::terminate_translator (Translator*r_l) Translator * Translator_group::remove_translator_p (Translator*trans_l) { + assert (trans_l); + PCursor trans_cur (trans_p_list_.find (trans_l)); Translator * t = trans_cur.remove_p(); /*