Ticket #10329: deletemap_tracker_fix.patch

File deletemap_tracker_fix.patch, 4.0 KB (added by Jim Stichnoth <stichnot@…>, 8 years ago)
  • mythtv/libs/libmythtv/deletemap.cpp

    diff --git a/mythtv/libs/libmythtv/deletemap.cpp b/mythtv/libs/libmythtv/deletemap.cpp
    index 4f75d13..d565930 100644
    a b 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    {
    uint64_t DeleteMap::GetNearestMark( 
    574579            result = it.key();
    575580        }
    576581    }
     582    if (hasMark)
     583        *hasMark = false;
    577584    return result;
    578585}
    579586
    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
    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}
    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);
  • mythtv/libs/libmythtv/deletemap.h

    diff --git a/mythtv/libs/libmythtv/deletemap.h b/mythtv/libs/libmythtv/deletemap.h
    index cbc0623..f111ca3 100644
    a b typedef struct DeleteMapUndoEntry 
    1919class MTV_PUBLIC DeleteMap
    2020{
    2121  public:
    22     DeleteMap(): m_editing(false),   m_nextCutStart(0), m_changed(true),
     22    DeleteMap(): m_editing(false),
     23                 m_nextCutStartIsValid(false),
     24                 m_nextCutStart(0), m_changed(true),
    2325                 m_seekamountpos(4), m_seekamount(30),
    2426                 m_ctx(0), m_undoStackPointer(-1) { Push(""); }
    2527
    class MTV_PUBLIC DeleteMap 
    5658    void Move(uint64_t frame, uint64_t to, uint64_t total);
    5759
    5860    bool     IsInDelete(uint64_t frame) const;
    59     uint64_t GetNearestMark(uint64_t frame, uint64_t total, bool right) const;
     61    uint64_t GetNearestMark(uint64_t frame, uint64_t total, bool right,
     62                            bool *hasMark = 0) const;
    6063    bool     IsTemporaryMark(uint64_t frame) const;
    6164    bool     HasTemporaryMark(void) const;
    6265    uint64_t GetLastFrame(uint64_t total) const;
    class MTV_PUBLIC DeleteMap 
    7982    void Push(QString undoMessage);
    8083
    8184    bool          m_editing;
     85    bool          m_nextCutStartIsValid;
    8286    uint64_t      m_nextCutStart;
    8387    frm_dir_map_t m_deleteMap;
    8488    QString       m_seekText;