Fix Track Moving not Updating PatternClipView (#8155)

This bug was noticed when testing out #7559, but the PR had been open for over a year, so it was decided to merge it and fix it in this one.

Basically, when adding or removing a track, the TrackContainer sends out signals such as trackAdded or trackRemoved which PatternClipView uses to know when to update.

However, it does not send out a signal when a track has been moved.

This is because for some reason, it's done by the GUI TrackContainerView instead of the core TrackContainer.

This PR changes that by moving the core code to the core where it probably belongs, adding an appropriate trackMoved signal to TrackContainer, and connecting that to PatternClipView to update properly.

---------

Co-authored-by: Fawn <rubiefawn@gmail.com>
This commit is contained in:
regulus79
2025-12-03 16:29:12 -05:00
committed by GitHub
parent 94f3b9704a
commit 0187e64ceb
4 changed files with 13 additions and 4 deletions

View File

@@ -68,6 +68,7 @@ public:
void addTrack( Track * _track );
void removeTrack( Track * _track );
void moveTrack(Track* track, int indexTo);
virtual void updateAfterTrackAdd();
@@ -100,6 +101,7 @@ public:
signals:
void trackAdded( lmms::Track * _track );
void trackRemoved();
void trackMoved();
protected:
static AutomatedValueMap automatedValuesFromTracks(const TrackList &tracks, TimePos timeStart, int clipNum = -1);

View File

@@ -214,6 +214,13 @@ void TrackContainer::removeTrack( Track * _track )
}
}
void TrackContainer::moveTrack(Track* track, int indexTo)
{
m_tracks.erase(std::find(m_tracks.begin(), m_tracks.end(), track));
m_tracks.insert(m_tracks.begin() + indexTo, track);
emit trackMoved();
}

View File

@@ -54,6 +54,8 @@ PatternClipView::PatternClipView(Clip* _clip, TrackView* _tv) :
this, &PatternClipView::update);
connect(Engine::patternStore(), &TrackContainer::trackRemoved,
this, &PatternClipView::update);
connect(Engine::patternStore(), &TrackContainer::trackMoved,
this, &PatternClipView::update);
setStyle( QApplication::style() );
}

View File

@@ -199,13 +199,11 @@ void TrackContainerView::moveTrackView( TrackView * trackView, int indexTo )
PatternTrack::swapPatternTracks( trackView->getTrack(),
m_trackViews[indexTo]->getTrack() );
m_tc->moveTrack(trackView->getTrack(), indexTo);
m_scrollLayout->removeWidget( trackView );
m_scrollLayout->insertWidget( indexTo, trackView );
Track * track = m_tc->m_tracks[indexFrom];
m_tc->m_tracks.erase(m_tc->m_tracks.begin() + indexFrom);
m_tc->m_tracks.insert(m_tc->m_tracks.begin() + indexTo, track);
m_trackViews.move( indexFrom, indexTo );
realignTracks();