@@ -549,13 +549,18 @@ bool DeleteMap::IsTemporaryMark(uint64_t frame) const
549549}
550550
551551/* *
552- * \brief Returns the next or previous mark. If these do not exist, returns
553- * either zero (the first frame) or total (the last frame).
552+ * \brief Returns the next or previous mark. If these do not exist,
553+ * returns either zero (the first frame) or total (the last
554+ * frame). If hasMark is non-NULL, it is set to true if the
555+ * next/previous mark exists, and false otherwise.
554556 */
555557uint64_t DeleteMap::GetNearestMark (
556- uint64_t frame, uint64_t total, bool right) const
558+ uint64_t frame, uint64_t total, bool right,
559+ bool *hasMark) const
557560{
558561 uint64_t result;
562+ if (hasMark)
563+ *hasMark = true ;
559564 frm_dir_map_t ::const_iterator it = m_deleteMap.begin ();
560565 if (right)
561566 {
@@ -574,6 +579,8 @@ uint64_t DeleteMap::GetNearestMark(
574579 result = it.key ();
575580 }
576581 }
582+ if (hasMark)
583+ *hasMark = false ;
577584 return result;
578585}
579586
@@ -740,6 +747,7 @@ void DeleteMap::SaveMap(uint64_t total, bool isAutoSave)
740747void DeleteMap::TrackerReset (uint64_t frame, uint64_t total)
741748{
742749 m_nextCutStart = 0 ;
750+ m_nextCutStartIsValid = false ;
743751 if (IsEmpty ())
744752 return ;
745753
@@ -748,16 +756,19 @@ void DeleteMap::TrackerReset(uint64_t frame, uint64_t total)
748756 {
749757 if (cutpoint.value () == MARK_CUT_START)
750758 {
759+ m_nextCutStartIsValid = true ;
751760 m_nextCutStart = cutpoint.key ();
752761 }
753762 else
754763 {
755764 ++cutpoint;
756- m_nextCutStart = cutpoint != m_deleteMap.end () ? cutpoint.key () : total;
765+ m_nextCutStartIsValid = (cutpoint != m_deleteMap.end ());
766+ m_nextCutStart = m_nextCutStartIsValid ? cutpoint.key () : total;
757767 }
758768 }
759769 else
760- m_nextCutStart = GetNearestMark (frame, total, !IsInDelete (frame));
770+ m_nextCutStart = GetNearestMark (frame, total, !IsInDelete (frame),
771+ &m_nextCutStartIsValid);
761772 LOG (VB_PLAYBACK, LOG_INFO, LOC + QString (" Tracker next CUT_START: %1" )
762773 .arg (m_nextCutStart));
763774}
@@ -768,7 +779,7 @@ void DeleteMap::TrackerReset(uint64_t frame, uint64_t total)
768779 */
769780bool DeleteMap::TrackerWantsToJump (uint64_t frame, uint64_t total, uint64_t &to)
770781{
771- if (IsEmpty () || frame < m_nextCutStart)
782+ if (IsEmpty () || !m_nextCutStartIsValid || frame < m_nextCutStart)
772783 return false ;
773784
774785 to = GetNearestMark (m_nextCutStart, total, true );
0 commit comments