Skip to content

Commit 7cd65b0

Browse files
committed
Fix empty MIDI clips not displaying name (LMMS#7808)
Beat clips don't render titles. checkType() always sets type to beat when there are no notes, so titles don't render on empty MIDI clips either.
1 parent 1721534 commit 7cd65b0

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/tracks/MidiClip.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace lmms
4242
MidiClip::MidiClip( InstrumentTrack * _instrument_track ) :
4343
Clip( _instrument_track ),
4444
m_instrumentTrack( _instrument_track ),
45-
m_clipType( Type::BeatClip ),
45+
m_clipType( Type::MelodyClip ),
4646
m_steps( TimePos::stepsPerBar() )
4747
{
4848
if (_instrument_track->trackContainer() == Engine::patternStore())
@@ -403,10 +403,13 @@ void MidiClip::setType( Type _new_clip_type )
403403

404404
void MidiClip::checkType()
405405
{
406-
// If all notes are StepNotes, we have a BeatClip
407-
const auto beatClip = std::all_of(m_notes.begin(), m_notes.end(), [](auto note) { return note->type() == Note::Type::Step; });
406+
// Clip type can only be checked if there are notes
407+
if (!m_notes.empty()) {
408+
// If all notes are StepNotes, we have a BeatClip
409+
const auto beatClip = std::all_of(m_notes.begin(), m_notes.end(), [](auto note) { return note->type() == Note::Type::Step; });
408410

409-
setType(beatClip ? Type::BeatClip : Type::MelodyClip);
411+
setType(beatClip ? Type::BeatClip : Type::MelodyClip);
412+
}
410413
}
411414

412415

@@ -416,7 +419,7 @@ void MidiClip::saveSettings( QDomDocument & _doc, QDomElement & _this )
416419
{
417420
_this.setAttribute( "type", static_cast<int>(m_clipType) );
418421
_this.setAttribute( "name", name() );
419-
422+
420423
if (const auto& c = color())
421424
{
422425
_this.setAttribute("color", c->name());

0 commit comments

Comments
 (0)