Merge pull request #5469 from Veratil/issue-5254
Set AutomationPattern length to 1 bar if the length is 0
This commit is contained in:
@@ -178,9 +178,16 @@ 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<tick_t>((it-1).key());
|
||||
// if last_tick is 0 (single item at tick 0)
|
||||
// return length as a whole bar to prevent disappearing TCO
|
||||
if (last_tick == 0) { return one_bar; }
|
||||
|
||||
return MidiTime(last_tick);
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +195,8 @@ MidiTime AutomationPattern::timeMapLength() const
|
||||
|
||||
void AutomationPattern::updateLength()
|
||||
{
|
||||
changeLength( timeMapLength() );
|
||||
// Do not resize down in case user manually extended up
|
||||
changeLength(qMax(length(), timeMapLength()));
|
||||
}
|
||||
|
||||
|
||||
@@ -223,12 +231,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 +254,7 @@ void AutomationPattern::removeValue( const MidiTime & time )
|
||||
}
|
||||
generateTangents(it, 3);
|
||||
|
||||
if( getTrack() && getTrack()->type() == Track::HiddenAutomationTrack )
|
||||
{
|
||||
updateLength();
|
||||
}
|
||||
updateLength();
|
||||
|
||||
emit dataChanged();
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user