[mythtv] [PATCH] (take 2) minor fix to "sort by program id"

Bruce Markey bjm at lvcm.com
Wed Feb 9 09:57:08 UTC 2005


John Patrick Poet wrote:
> John Patrick Poet wrote:
> 
>>
>> When in the "Default" or "All Programs" section of the programs list, 
>> it was not finding the correct program position after some "sub 
>> action" was performed.  This patch should fix that.
>>
>> John
> 
> 
> Ack!  Pretend the previous message never existed.  Please don't apply 
> programid-sort.patch.  Bruce already fixed that problem, and I wrote a 
> "fix" for a problem that did not exist.
> 
> Please do apply programid-sort-v2.patch.  This patch fixes the case 
> where you have multiple instances of the same ProgramID - for example, 
> if the mythbackend is restarted in the middle of a record.  Without this 
> patch it would always jump to the last show with the same ProgramID 
> instead of finding the correct location.

That shouldn't happen. The sections for:

            if (episodeSort == "Id" && titleView && titleIndex > 0)
            {
                if (oldprogramid > p->programid)
                    break;
            }
            else if (listOrder == 0 || type == Delete)
            {
                if (oldstartts > p->startts)
                    break;
            }
            else
            {
                if (oldstartts < p->startts)
                    break;
            }

are checking if we have gone past the item while going backwards
through the list. This should only happen if the item had been
deleted. By breaking without incrementing "i" it puts the focus
on the item after the one that had been deleted.

This is the code that checks for a match:

            if (oldchanid == p->chanid &&
                oldstartts == p->startts)
                break;

If a program was stopped and restarted the startts' would be different
and it should stop on the right one.

When the focus shifts to the bottom item on the list, that means
that the check to see if we have gone past the item is incorrectly
true right away. If it didn't find a match and these checks always
failed, the focus would end up at the top of the list.

It would "always jump to the last show with the same ProgramID"
if the test was:

         if (oldprogramid >= p->programid)

because as it was coming up the list from the bottom, it would
stop on the first item that matched the programid without ever
checking the chanid and startts. Therefore it needs to be ">"
and not ">=".

--  bjm


More information about the mythtv-dev mailing list