From 3d46ea2c97ddd6bfe2c93e98dafee8a295169baa Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Thu, 3 Apr 2008 22:50:04 +0000 Subject: [PATCH] optimized track::length()-method git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@879 0778d3d1-df1d-0410-868b-ea421aaaa00d --- src/core/track.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/core/track.cpp b/src/core/track.cpp index 7821f35e3..41ff3ac2b 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -106,6 +106,7 @@ void trackContentObject::movePosition( const midiTime & _pos ) { addJournalEntry( journalEntry( Move, m_startPosition - _pos ) ); m_startPosition = _pos; + engine::getSong()->updateLength(); } emit positionChanged(); } @@ -119,6 +120,7 @@ void trackContentObject::changeLength( const midiTime & _length ) { addJournalEntry( journalEntry( Resize, m_length - _length ) ); m_length = _length; + engine::getSong()->updateLength(); } emit lengthChanged(); } @@ -1615,13 +1617,17 @@ void track::removeTact( const midiTime & _pos ) tact track::length( void ) const { // find last end-position - midiTime last = 0; + Sint32 last = 0; for( tcoVector::const_iterator it = m_trackContentObjects.begin(); it != m_trackContentObjects.end(); ++it ) { - last = tMax( ( *it )->endPosition(), last ); + const Sint32 cur = ( *it )->endPosition(); + if( cur > last ) + { + last = cur; + } } - return( last.getTact() + ( ( last.getTact64th() != 0 ) ? 1 : 0 ) ); + return( last/64 + 1 ); }