[mythtv-commits] Ticket #9737: Editing channel number in frontend brings to lose channels

MythTV noreply at mythtv.org
Mon Apr 18 13:00:10 UTC 2011


#9737: Editing channel number in frontend brings to lose channels
-------------------------------------+----------------------------------
 Reporter:  luigi.zanderighi@…       |           Type:  Patch - Feature
   Status:  new                      |       Priority:  minor
Milestone:  unknown                  |      Component:  MythTV - General
  Version:  Unspecified              |       Severity:  medium
 Keywords:  channel editor live_tv   |  Ticket locked:  0
-------------------------------------+----------------------------------
 During a channel renumbering in the frontend channels can get unreachable.

 I have two channels with numbering 10 and 20, i would like to renumber
 channel 20 to channel 10. Using the frontend in live-tv mode i renumber
 the channel, but now I have two channles with numbers 10.
 One is available the second one not.
 To manage the a correct channel renumbering I should put channel 10 in an
 unused channel number, and than put channel 20 in channel 10.

 To solve this issue, the channels could be automatically swapped. So if i
 put channel 20->10 automatically channel 10->20.

 In attachment the patch for file tv_rec.cpp

 bool TVRec::SetChannelInfo(uint chanid, uint sourceid,
                            QString oldchannum,
                            QString callsign, QString channum,
                            QString channame, QString xmltvid)
 {
     if (!chanid || !sourceid || channum.isEmpty())
         return false;
 //LZ: 'swap' channels not only update
     MSqlQuery swapquery(MSqlQuery::InitCon());
     query.prepare(
         "UPDATE channel "
         "SET channum  = :OLDCHANNUM,  "
         "WHERE channum   = :CHANNUM AND "
         "      sourceid = :SOURCEID");
     swapquery.bindValue(":CHANNUM",  channum);
     swapquery.bindValue(":SOURCEID", channame);
     swapquery.bindValue(":OLDCHANNUM",  xmltvid);


     MSqlQuery query(MSqlQuery::InitCon());
     query.prepare(
         "UPDATE channel "
         "SET callsign = :CALLSIGN, "
         "    channum  = :CHANNUM,  "
         "    name     = :CHANNAME, "
         "    xmltvid  = :XMLTVID   "
         "WHERE chanid   = :CHANID AND "
         "      sourceid = :SOURCEID");
     query.bindValue(":CALLSIGN", callsign);
     query.bindValue(":CHANNUM",  channum);
     query.bindValue(":CHANNAME", channame);
     query.bindValue(":XMLTVID",  xmltvid);
     query.bindValue(":CHANID",   chanid);
     query.bindValue(":SOURCEID", sourceid);

     if (!query.exec() || !swapquery.exec())
     {
         MythDB::DBError("SetChannelInfo", query);
         return false;
     }

     if (channel)
         channel->Renumber(sourceid, oldchannum, channum);

     return true;
 }

-- 
Ticket URL: <http://code.mythtv.org/trac/ticket/9737>
MythTV <http://code.mythtv.org/trac>
MythTV Media Center


More information about the mythtv-commits mailing list