Ticket #12081: 12081_possible_fix.diff

File 12081_possible_fix.diff, 5.2 KB (added by stuartm, 6 years ago)
  • mythtv/libs/libmyth/programinfo.cpp

    commit 671795aa01dcf0689b06f64ffa362e27f0c0e3a1
    Author: Stuart Morgan <smorgan@mythtv.org>
    Date:   Thu Mar 27 17:35:03 2014 +0000
    
        Fix some confusion over the behaviour/purpose of IsSameProgram
    
        Creates a new method similar to IsSameProgram called
        IsDuplicateProgram which is purely used for scheduling purposes.
    
        The issue seems to be that IsSameProgram() doesn't do what it appears
        it should. Places using it assume that it will match two
        programs which are identical - same content - but it's been modified
        over time to serve the definition of a 'duplicate' for scheduling
        purposes. This means, among other things, that if the duplicate check
        method is 'None', then IsSameProgram will return false given two
        identical programs.
    
    diff --git a/mythtv/libs/libmyth/programinfo.cpp b/mythtv/libs/libmyth/programinfo.cpp
    index 06cc019..a61317d 100644
    a b bool ProgramInfo::IsSameProgramWeakCheck(const ProgramInfo &other) const 
    20512051 *  \brief Checks for duplicates according to dupmethod.
    20522052 *  \param other ProgramInfo to compare this one with.
    20532053 */
    2054 bool ProgramInfo::IsSameProgram(const ProgramInfo& other) const
     2054bool ProgramInfo::IsDuplicateProgram(const ProgramInfo& other) const
    20552055{
    20562056    if (GetRecordingRuleType() == kOneRecord)
    20572057        return recordid == other.recordid;
    bool ProgramInfo::IsSameProgram(const ProgramInfo& other) const 
    21152115}
    21162116
    21172117/**
     2118 *  \brief Checks whether this is the same program as "other", which may or may
     2119 *         not be a repeat or on another channel. Matches based on programid
     2120 *         with a fallback to dupmethod
     2121 *  \param other ProgramInfo to compare this one with.
     2122 */
     2123bool ProgramInfo::IsSameProgram(const ProgramInfo& other) const
     2124{
     2125    if (title.compare(other.title, Qt::CaseInsensitive) != 0)
     2126        return false;
     2127
     2128    if (!programid.isEmpty() && !other.programid.isEmpty())
     2129    {
     2130        if (catType == kCategorySeries)
     2131        {
     2132            if (programid.endsWith("0000"))
     2133                return false;
     2134        }
     2135
     2136        if (usingProgIDAuth)
     2137        {
     2138            int index = programid.indexOf('/');
     2139            int oindex = other.programid.indexOf('/');
     2140            if (index == oindex && (index < 0 ||
     2141                programid.leftRef(index) == other.programid.leftRef(oindex)))
     2142                return programid == other.programid;
     2143        }
     2144        else
     2145        {
     2146            return programid == other.programid;
     2147        }
     2148    }
     2149
     2150    if ((dupmethod & kDupCheckSub) &&
     2151        ((subtitle.isEmpty()) ||
     2152         (subtitle.compare(other.subtitle, Qt::CaseInsensitive) != 0)))
     2153        return false;
     2154
     2155    if ((dupmethod & kDupCheckDesc) &&
     2156        ((description.isEmpty()) ||
     2157         (description.compare(other.description, Qt::CaseInsensitive) != 0)))
     2158        return false;
     2159
     2160    if ((dupmethod & kDupCheckSubThenDesc) &&
     2161        ((subtitle.isEmpty() &&
     2162          ((!other.subtitle.isEmpty() &&
     2163            description.compare(other.subtitle, Qt::CaseInsensitive) != 0) ||
     2164           (other.subtitle.isEmpty() &&
     2165            description.compare(other.description, Qt::CaseInsensitive) != 0))) ||
     2166         (!subtitle.isEmpty() &&
     2167          ((other.subtitle.isEmpty() &&
     2168            subtitle.compare(other.description, Qt::CaseInsensitive) != 0) ||
     2169           (!other.subtitle.isEmpty() &&
     2170            subtitle.compare(other.subtitle, Qt::CaseInsensitive) != 0)))))
     2171        return false;
     2172
     2173    return true;
     2174}
     2175
     2176/**
    21182177 *  \brief Match same program, with same starttime (channel may be different)
    21192178 *  \param other ProgramInfo to compare this one with.
    21202179 *  \return true if this program is the same and shares same start time as "other" program.
  • mythtv/libs/libmyth/programinfo.h

    diff --git a/mythtv/libs/libmyth/programinfo.h b/mythtv/libs/libmyth/programinfo.h
    index 161c34a..d2e2bee 100644
    a b class MPUBLIC ProgramInfo 
    298298    virtual void SubstituteMatches(QString &str);
    299299
    300300    // Used for scheduling recordings
    301     bool IsSameProgram(const ProgramInfo &other) const;
     301    bool IsSameProgram(const ProgramInfo &other) const; // Exact same program
     302    bool IsDuplicateProgram(const ProgramInfo &other) const; // Is this program considered a duplicate according to rule type and dup method (scheduler only)
    302303    bool IsSameProgramAndStartTime(const ProgramInfo &other) const; // Exact same program and same starttime, Any channel
    303304    bool IsSameTitleStartTimeAndChannel(const ProgramInfo &other) const; // Same title, starttime and channel
    304305    bool IsSameTitleTimeslotAndChannel(const ProgramInfo &other) const;//sched only - Same title, starttime, endtime and channel
  • mythtv/programs/mythbackend/scheduler.cpp

    diff --git a/mythtv/programs/mythbackend/scheduler.cpp b/mythtv/programs/mythbackend/scheduler.cpp
    index 55ed297..e11487e 100644
    a b bool Scheduler::IsSameProgram( 
    10241024    if (it != cache_is_same_program.end())
    10251025        return *it;
    10261026
    1027     return cache_is_same_program[X] = a->IsSameProgram(*b);
     1027    return cache_is_same_program[X] = a->IsDuplicateProgram(*b);
    10281028}
    10291029
    10301030bool Scheduler::FindNextConflict(