Skip to content

Commit a883d75

Browse files
committed
Fix markers disappear on move clip undo
As reported here: https://forum.shotcut.org/t/all-markers-disappeared-after-about-100/51206
1 parent 2c0013a commit a883d75

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/commands/timelinecommands.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ MoveClipCommand::MoveClipCommand(
641641
, m_undoHelper(m_model)
642642
, m_redo(false)
643643
, m_earliestStart(-1)
644+
, m_markersModified(-1)
644645
{
645646
m_undoHelper.setHints(UndoHelper::RestoreTracks);
646647
m_undoHelper.recordBeforeState();
@@ -810,7 +811,7 @@ void MoveClipCommand::undo()
810811
{
811812
LOG_DEBUG() << "track delta" << m_trackDelta;
812813
m_undoHelper.undoChanges();
813-
if (m_rippleMarkers && m_markers.size() >= 0) {
814+
if (m_rippleMarkers && m_markersModified == 1) {
814815
m_markersModel.doReplace(m_markers);
815816
}
816817
// Select the original clips after undo.
@@ -852,28 +853,28 @@ bool MoveClipCommand::mergeWith(const QUndoCommand *other)
852853

853854
void MoveClipCommand::redoMarkers()
854855
{
855-
if (m_rippleMarkers) {
856+
if (m_rippleMarkers && m_markersModified == -1) {
857+
m_markersModified = 0;
856858
if (m_markers.size() == 0) {
857859
m_markers = m_markersModel.getMarkers();
858860
}
859861
QList<Markers::Marker> newMarkers = m_markers;
860-
bool markersModified = false;
861862
for (int i = 0; i < newMarkers.size(); i++) {
862863
Markers::Marker &marker = newMarkers[i];
863864
if (marker.start < m_earliestStart
864865
&& marker.start > (m_earliestStart + m_positionDelta)) {
865866
// This marker is in the overwritten segment. Remove it
866867
newMarkers.removeAt(i);
867868
i--;
868-
markersModified = true;
869+
m_markersModified = 1;
869870
} else if (marker.start >= m_earliestStart) {
870871
// This marker is after the start of the moved segment. Shift it with the move
871872
marker.start += m_positionDelta;
872873
marker.end += m_positionDelta;
873-
markersModified = true;
874+
m_markersModified = 1;
874875
}
875876
}
876-
if (markersModified) {
877+
if (m_markersModified == 1) {
877878
m_markersModel.doReplace(newMarkers);
878879
} else {
879880
m_markers.clear();

src/commands/timelinecommands.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ class MoveClipCommand : public QUndoCommand
347347
bool m_redo;
348348
int m_earliestStart;
349349
QList<Markers::Marker> m_markers;
350+
int m_markersModified;
350351
};
351352

352353
class TrimCommand : public QUndoCommand

0 commit comments

Comments
 (0)