diff --git a/src/gui/model/parent-track.cpp b/src/gui/model/parent-track.cpp index d46f007f4..f7122fe46 100644 --- a/src/gui/model/parent-track.cpp +++ b/src/gui/model/parent-track.cpp @@ -51,22 +51,17 @@ ParentTrack::can_host_children() const } bool -ParentTrack::remove_descendant_track(const boost::shared_ptr track) +ParentTrack::remove_descendant_track( + const boost::shared_ptr track) { REQUIRE(track); - BOOST_FOREACH(const boost::shared_ptr child_track, tracks) + boost::shared_ptr parent = + find_descendant_track_parent(track); + if(parent) { - REQUIRE(child_track); - - if(track.get() == child_track.get()) - { - tracks.remove(track); - return true; - } - - if(child_track->remove_descendant_track(track)) - return true; + parent->tracks.remove(track); + return true; } return false; diff --git a/src/gui/model/track.cpp b/src/gui/model/track.cpp index f2c52b19d..7e9a3992b 100644 --- a/src/gui/model/track.cpp +++ b/src/gui/model/track.cpp @@ -61,12 +61,6 @@ Track::can_host_children() const return false; } -bool -Track::remove_descendant_track(const shared_ptr /*track*/) -{ - return false; -} - string Track::print_branch() { diff --git a/src/gui/model/track.hpp b/src/gui/model/track.hpp index 7bc0e7c45..ac137d451 100644 --- a/src/gui/model/track.hpp +++ b/src/gui/model/track.hpp @@ -69,16 +69,7 @@ public: * Returns true if this track can own any child tracks. **/ virtual bool can_host_children() const; - - /** - * Tries to remove a given track from amongst the descendants of this - * track. - * @param The model track to try and remove. - * @return Returns true if the track was successfully removed. - **/ - virtual bool remove_descendant_track( - const boost::shared_ptr track); - + /** * A utility function that attempts to find the parent of a track by * searching through the tree from this track downward.