diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index b38c704ef..9a8bdca15 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -178,9 +178,19 @@ const AutomationPattern::objectVector& AutomationPattern::objects() const MidiTime AutomationPattern::timeMapLength() const { - if( m_timeMap.isEmpty() ) return 0; + MidiTime one_bar = MidiTime(1, 0); + if (m_timeMap.isEmpty()) + { + return one_bar; + } timeMap::const_iterator it = m_timeMap.end(); - return MidiTime( MidiTime( (it-1).key() ).nextFullBar(), 0 ); + tick_t last_tick = static_cast((it-1).key()); + bar_t last_bar = qMax(0, MidiTime(last_tick).nextFullBar() - 1); + if (last_bar == 0 && last_tick == 0) + { + return one_bar; + } + return MidiTime(last_bar, last_tick); } @@ -223,12 +233,7 @@ MidiTime AutomationPattern::putValue( const MidiTime & time, } generateTangents( it, 3 ); - // we need to maximize our length in case we're part of a hidden - // automation track as the user can't resize this pattern - if( getTrack() && getTrack()->type() == Track::HiddenAutomationTrack ) - { - updateLength(); - } + updateLength(); emit dataChanged(); @@ -251,10 +256,7 @@ void AutomationPattern::removeValue( const MidiTime & time ) } generateTangents(it, 3); - if( getTrack() && getTrack()->type() == Track::HiddenAutomationTrack ) - { - updateLength(); - } + updateLength(); emit dataChanged(); } diff --git a/src/core/Track.cpp b/src/core/Track.cpp index cb430da96..0c046a504 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -159,7 +159,7 @@ void TrackContentObject::movePosition( const MidiTime & pos ) /*! \brief Change the length of this TrackContentObject * - * If the track content object's length has chaanged, update it. We + * If the track content object's length has changed, update it. We * also add a journal entry for undo and update the display. * * \param _length The new length of the track content object.