From d272f8420ae293dd988b57a4943727f7a878123a Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 19 Dec 2006 23:40:14 +0100 Subject: [PATCH] robustness fix: allow Music_wrapper with null child. Fixes #177 --- lily/music-wrapper-iterator.cc | 17 ++++++++++++----- lily/music-wrapper.cc | 5 ++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lily/music-wrapper-iterator.cc b/lily/music-wrapper-iterator.cc index e89896ce66..bc59a303a6 100644 --- a/lily/music-wrapper-iterator.cc +++ b/lily/music-wrapper-iterator.cc @@ -18,7 +18,8 @@ Music_wrapper_iterator::Music_wrapper_iterator () void Music_wrapper_iterator::do_quit () { - child_iter_->quit (); + if (child_iter_) + child_iter_->quit (); } void @@ -40,7 +41,9 @@ Music_wrapper_iterator::construct_children () { Music *my_music = get_music (); Music *child = unsmob_music (my_music->get_property ("element")); - child_iter_ = unsmob_iterator (get_iterator (child)); + child_iter_ = (child) + ? unsmob_iterator (get_iterator (child)) + : 0; } bool @@ -52,13 +55,17 @@ Music_wrapper_iterator::ok () const void Music_wrapper_iterator::process (Moment m) { - child_iter_->process (m); + if (child_iter_) + child_iter_->process (m); } Moment Music_wrapper_iterator::pending_moment () const { - return child_iter_->pending_moment (); + if (child_iter_) + return child_iter_->pending_moment (); + else + return Music_iterator::pending_moment (); } IMPLEMENT_CTOR_CALLBACK (Music_wrapper_iterator); @@ -66,5 +73,5 @@ IMPLEMENT_CTOR_CALLBACK (Music_wrapper_iterator); bool Music_wrapper_iterator::run_always () const { - return child_iter_->run_always (); + return (child_iter_ && child_iter_->run_always ()); } diff --git a/lily/music-wrapper.cc b/lily/music-wrapper.cc index 051187a8a4..5f141c0c91 100644 --- a/lily/music-wrapper.cc +++ b/lily/music-wrapper.cc @@ -16,7 +16,10 @@ Music_wrapper::start_callback (SCM m) { Music *me = unsmob_music (m); Music *elt = unsmob_music (me->get_property ("element")); - return elt->start_mom ().smobbed_copy (); + if (elt) + return elt->start_mom ().smobbed_copy (); + else + return Moment ().smobbed_copy (); } MAKE_SCHEME_CALLBACK (Music_wrapper, length_callback, 1); -- 2.39.5