[mythtv] Minor bug in scheduler

Benjamin Binford mythtv-dev@snowman.net
Fri, 6 Dec 2002 07:11:51 -0500


--2fHTh5uZTiUOsy+g
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Thu, Dec 05, 2002 at 10:43:02PM -0500, Isaac Richards wrote:
> On Thursday 05 December 2002 12:13 pm, Benjamin Binford wrote:
> > I think I've uncovered a minor bug in the scheduler. This is easiest
> > to reproduce if you have back to back episodes of a tv show somewhere
> > in your schedule. On one of the shows select a timeslot record, on the
> > other select record all. If you look into the fix conflicts screen you'll
> > see that for the show that you selected timeslot record there are duplicate
> > entries.
> >
> > Attached is a patch which fixes this by checking for duplicate shows
> > on the same channel, source, and time in Scheduler::PruneList in addition
> > to checking for description and title matching.
> 
> Mind regenerating that with diff -u?

Sorry, I'm something of an idiot when it comes to cvs and patches. Here you go.

--2fHTh5uZTiUOsy+g
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="schedulerfix.patch"

Index: libs/libmyth/programinfo.cpp
===================================================================
RCS file: /var/lib/cvs/MC/libs/libmyth/programinfo.cpp,v
retrieving revision 1.18
diff -u -r1.18 programinfo.cpp
--- libs/libmyth/programinfo.cpp	4 Dec 2002 05:33:22 -0000	1.18
+++ libs/libmyth/programinfo.cpp	6 Dec 2002 12:07:20 -0000
@@ -512,3 +512,33 @@
     }
 
 }
+
+
+
+bool ProgramInfo::IsSameProgram(const ProgramInfo& other) const
+{
+    if (title == other.title &&
+	subtitle.length() > 2 &&
+	description.length() > 2 &&
+	subtitle == other.subtitle &&
+	description == other.description)
+      return true;
+    else
+      return false;
+}
+  
+bool ProgramInfo::IsSameTimeslot(const ProgramInfo& other) const
+{
+    if (chanid == other.chanid &&
+	startts == other.startts &&
+	endts == other.endts &&
+	sourceid == other.sourceid &&
+	cardid == other.cardid &&
+	inputid == other.inputid)
+      return true;
+    else
+      return false;
+}
+
+
+
Index: libs/libmyth/programinfo.h
===================================================================
RCS file: /var/lib/cvs/MC/libs/libmyth/programinfo.h,v
retrieving revision 1.10
diff -u -r1.10 programinfo.h
--- libs/libmyth/programinfo.h	4 Dec 2002 05:33:22 -0000	1.10
+++ libs/libmyth/programinfo.h	6 Dec 2002 12:07:20 -0000
@@ -21,7 +21,8 @@
   public:
     ProgramInfo();
     ProgramInfo(const ProgramInfo &other);
-
+    bool IsSameProgram(const ProgramInfo& other) const;
+    bool IsSameTimeslot(const ProgramInfo& other) const;
     // returns 0 for one-time, 1 for weekdaily, 2 for weekly
     int IsProgramRecurring(void);
 
Index: programs/mythfrontend/scheduler.cpp
===================================================================
RCS file: /var/lib/cvs/MC/programs/mythfrontend/scheduler.cpp,v
retrieving revision 1.30
diff -u -r1.30 scheduler.cpp
--- programs/mythfrontend/scheduler.cpp	4 Dec 2002 05:33:22 -0000	1.30
+++ programs/mythfrontend/scheduler.cpp	6 Dec 2002 12:07:22 -0000
@@ -511,7 +511,7 @@
     QSqlQuery query;
     QString thequery;
    
-    if (pginfo->subtitle == "" || pginfo->description == "")
+    if (pginfo->subtitle.length() <= 2 || pginfo->description.length() < 2)
         return false;
 
     thequery = QString("SELECT NULL FROM oldrecorded WHERE "
@@ -538,9 +538,8 @@
         j++;
 
         ProgramInfo *first = (*i);
-
-        if (first->recordtype > kSingleRecord && 
-            (first->subtitle.length() > 2 && first->description.length() > 2))
+	
+        if (first->recordtype > kSingleRecord)
         {
             if (FindInOldRecordings(first))
             {
@@ -553,13 +552,19 @@
             {
                 for (; j != recordingList.rend(); j++)
                 {
+		  
                     ProgramInfo *second = (*j);
-                    if ((first->title == second->title) && 
-                        (first->subtitle == second->subtitle) &&
-                        (first->description == second->description) &&
-                        first->subtitle != "" && first->description != "")
+		    if (first->IsSameTimeslot(*second))
+		    {
+		        delete second;
+                        deliter = j.base();
+                        j++;
+                        deliter--;
+                        recordingList.erase(deliter);
+		    }
+		    else if (first->IsSameProgram(*second))
                     {
-                        if (second->conflicting && !first->conflicting)
+		      if (second->conflicting && !first->conflicting)
                         {
                             delete second;
                             deliter = j.base();

--2fHTh5uZTiUOsy+g--