Ticket #13571: 20200516-encoderlink-rc2.patch

File 20200516-encoderlink-rc2.patch, 10.8 KB (added by Klaas de Waal, 5 years ago)

Replacing Qt foreach loops with C++11 range loops and make all accesses const

  • mythtv/programs/mythbackend/httpstatus.cpp

    diff --git a/mythtv/programs/mythbackend/httpstatus.cpp b/mythtv/programs/mythbackend/httpstatus.cpp
    index ce10b085fb..110ef497c5 100644
    a b void HttpStatus::FillStatusXML( QDomDocument *pDoc ) 
    197197
    198198    TVRec::s_inputsLock.lockForRead();
    199199
    200     foreach (auto elink, *m_pEncoders)
     200    for (auto elink : qAsConst(*m_pEncoders))
    201201    {
    202202        if (elink != nullptr)
    203203        {
  • mythtv/programs/mythbackend/mainserver.cpp

    diff --git a/mythtv/programs/mythbackend/mainserver.cpp b/mythtv/programs/mythbackend/mainserver.cpp
    index ef16e5539c..af19beea53 100644
    a b void MainServer::HandleAnnounce(QStringList &slist, QStringList commands, 
    18631863
    18641864        bool wasAsleep = true;
    18651865        TVRec::s_inputsLock.lockForRead();
    1866         foreach (auto elink, *m_encoderList)
     1866        for (auto elink : qAsConst(*m_encoderList))
    18671867        {
    18681868            if (elink->GetHostName() == commands[2])
    18691869            {
    void MainServer::DoHandleStopRecording( 
    29302930                if (m_sched)
    29312931                    m_sched->UpdateRecStatus(&recinfo);
    29322932            }
     2933
     2934            break;
    29332935        }
    29342936    }
    29352937    TVRec::s_inputsLock.unlock();
    void MainServer::HandleLockTuner(PlaybackSock *pbs, int cardid) 
    42384240    QString enchost;
    42394241
    42404242    TVRec::s_inputsLock.lockForRead();
    4241     foreach (auto elink, *m_encoderList)
     4243    for (auto elink : qAsConst(*m_encoderList))
    42424244    {
    42434245        // we're looking for a specific card but this isn't the one we want
    42444246        if ((cardid != -1) && (cardid != elink->GetInputID()))
    void MainServer::HandleGetFreeInputInfo(PlaybackSock *pbs, 
    43604362    vector<InputInfo> freeinputs;
    43614363    QMap<uint, QSet<uint> > groupids;
    43624364
    4363     // Lopp over each encoder and divide the inputs into busy and free
    4364     // lists.
     4365    // Loop over each encoder and divide the inputs into busy and free lists.
    43654366    TVRec::s_inputsLock.lockForRead();
    4366     foreach (auto elink, *m_encoderList)
     4367    for (auto elink : qAsConst(*m_encoderList))
    43674368    {
    43684369        InputInfo info;
    43694370        info.m_inputId = elink->GetInputID();
    void MainServer::HandleSetChannelInfo(QStringList &slist, PlaybackSock *pbs) 
    48954896    }
    48964897
    48974898    TVRec::s_inputsLock.lockForRead();
    4898     foreach (auto & encoder, *m_encoderList)
     4899    for (auto encoder : qAsConst(*m_encoderList))
    48994900    {
    49004901        if (encoder)
    49014902        {
    49024903            ok &= encoder->SetChannelInfo(chanid, sourceid, oldcnum,
    4903                                         callsign, channum, channame, xmltv);
     4904                                          callsign, channum, channame, xmltv);
    49044905        }
    49054906    }
    49064907    TVRec::s_inputsLock.unlock();
    size_t MainServer::GetCurrentMaxBitrate(void) 
    50915092    size_t totalKBperMin = 0;
    50925093
    50935094    TVRec::s_inputsLock.lockForRead();
    5094     foreach (auto enc, *m_encoderList)
     5095    for (auto enc : qAsConst(*m_encoderList))
    50955096    {
    50965097        if (!enc->IsConnected() || !enc->IsBusy())
    50975098            continue;
    void MainServer::HandleIsRecording(QStringList &slist, PlaybackSock *pbs) 
    73287329    QStringList retlist;
    73297330
    73307331    TVRec::s_inputsLock.lockForRead();
    7331     foreach (auto elink, *m_encoderList)
     7332    for (auto elink : qAsConst(*m_encoderList))
    73327333    {
    73337334        if (elink->IsBusyRecording()) {
    73347335            RecordingsInProgress++;
    void MainServer::connectionClosed(MythSocket *socket) 
    77937794
    77947795                bool isFallingAsleep = true;
    77957796                TVRec::s_inputsLock.lockForRead();
    7796                 foreach (auto elink, *m_encoderList)
     7797                for (auto elink : qAsConst(*m_encoderList))
    77977798                {
    77987799                    if (elink->GetSocket() == pbs)
    77997800                    {
    void MainServer::connectionClosed(MythSocket *socket) 
    78347835                if (chain->HostSocketCount() == 0)
    78357836                {
    78367837                    TVRec::s_inputsLock.lockForRead();
    7837                     foreach (auto enc, *m_encoderList)
     7838                    for (auto enc : qAsConst(*m_encoderList))
    78387839                    {
    78397840                        if (enc->IsLocal())
    78407841                        {
    void MainServer::reconnectTimeout(void) 
    81818182    QStringList strlist( str );
    81828183
    81838184    TVRec::s_inputsLock.lockForRead();
    8184     foreach (auto elink, *m_encoderList)
     8185    for (auto elink : qAsConst(*m_encoderList))
    81858186    {
    81868187        elink->CancelNextRecording(true);
    81878188        ProgramInfo *pinfo = elink->GetRecording();
    void MainServer::UpdateSystemdStatus (void) 
    83548355    {
    83558356        int active = 0;
    83568357        TVRec::s_inputsLock.lockForRead();
    8357         foreach (auto elink, *m_encoderList)
     8358        for (auto elink : qAsConst(*m_encoderList))
    83588359        {
    83598360            if (not elink->IsLocal())
    83608361                continue;
  • mythtv/programs/mythbackend/scheduler.cpp

    diff --git a/mythtv/programs/mythbackend/scheduler.cpp b/mythtv/programs/mythbackend/scheduler.cpp
    index 2a1173df95..4a823f38df 100644
    a b void Scheduler::HandleWakeSlave(RecordingInfo &ri, int prerollseconds) 
    25242524    QReadLocker tvlocker(&TVRec::s_inputsLock);
    25252525
    25262526    QMap<int, EncoderLink*>::const_iterator tvit = m_tvList->constFind(ri.GetInputID());
    2527     if (tvit == m_tvList->end())
     2527    if (tvit == m_tvList->constEnd())
    25282528        return;
    25292529
    25302530    QString sysEventKey = ri.MakeUniqueKey();
    void Scheduler::HandleWakeSlave(RecordingInfo &ri, int prerollseconds) 
    26072607                    "to reschedule around its tuners.")
    26082608                .arg(nexttv->GetHostName()));
    26092609
    2610         foreach (auto & enc, *m_tvList)
     2610        for (auto enc : qAsConst(*m_tvList))
    26112611        {
    26122612            if (enc->GetHostName() == nexttv->GetHostName())
    26132613                enc->SetSleepStatus(sStatus_Undefined);
    bool Scheduler::HandleRecording( 
    26822682    QReadLocker tvlocker(&TVRec::s_inputsLock);
    26832683
    26842684    QMap<int, EncoderLink*>::const_iterator tvit = m_tvList->constFind(ri.GetInputID());
    2685     if (tvit == m_tvList->end())
     2685    if (tvit == m_tvList->constEnd())
    26862686    {
    26872687        QString msg = QString("Invalid cardid [%1] for %2")
    26882688            .arg(ri.GetInputID()).arg(ri.GetTitle());
    bool Scheduler::HandleRecording( 
    27642764                        "to reschedule around its tuners.")
    27652765                    .arg(nexttv->GetHostName()));
    27662766
    2767             foreach (auto enc, *m_tvList)
     2767            for (auto enc : qAsConst(*m_tvList))
    27682768            {
    27692769                if (enc->GetHostName() == nexttv->GetHostName())
    27702770                    enc->SetSleepStatus(sStatus_Undefined);
    void Scheduler::PutInactiveSlavesToSleep(void) 
    34523452    QReadLocker tvlocker(&TVRec::s_inputsLock);
    34533453
    34543454    bool someSlavesCanSleep = false;
    3455     foreach (auto enc, *m_tvList)
     3455    for (auto enc : qAsConst(*m_tvList))
    34563456    {
    34573457        if (enc->CanSleep())
    34583458            someSlavesCanSleep = true;
    void Scheduler::PutInactiveSlavesToSleep(void) 
    35333533    LOG(VB_SCHEDULE, LOG_DEBUG, QString("  Shutting down slaves which will "
    35343534        "be inactive for the next %1 minutes and can be put to sleep.")
    35353535            .arg(sleepThreshold / 60));
    3536 
    3537     foreach (auto enc, *m_tvList)
     3536    for (auto enc : qAsConst(*m_tvList))
    35383537    {
    35393538        if ((!enc->IsLocal()) &&
    35403539            (enc->IsAwake()) &&
    void Scheduler::PutInactiveSlavesToSleep(void) 
    35583557
    35593558                if (enc->GoToSleep())
    35603559                {
    3561                     foreach (auto slv, *m_tvList)
     3560                    for (auto slv : qAsConst(*m_tvList))
    35623561                    {
    35633562                        if (slv->GetHostName() == thisHost)
    35643563                        {
    void Scheduler::PutInactiveSlavesToSleep(void) 
    35763575                    LOG(VB_GENERAL, LOG_ERR, LOC +
    35773576                        QString("Unable to shutdown %1 slave backend, setting "
    35783577                                "sleep status to undefined.").arg(thisHost));
    3579                     foreach (auto slv, *m_tvList)
     3578                    for (auto slv : qAsConst(*m_tvList))
    35803579                    {
    35813580                        if (slv->GetHostName() == thisHost)
    35823581                            slv->SetSleepStatus(sStatus_Undefined);
    bool Scheduler::WakeUpSlave(const QString& slaveHostname, bool setWakingStatus) 
    36053604        LOG(VB_GENERAL, LOG_NOTICE,
    36063605            QString("Trying to Wake Up %1, but this slave "
    36073606                    "does not have a WakeUpCommand set.").arg(slaveHostname));
    3608 
    3609         foreach (auto enc, *m_tvList)
     3607        for (auto enc : qAsConst(*m_tvList))
    36103608        {
    36113609            if (enc->GetHostName() == slaveHostname)
    36123610                enc->SetSleepStatus(sStatus_Undefined);
    bool Scheduler::WakeUpSlave(const QString& slaveHostname, bool setWakingStatus) 
    36163614    }
    36173615
    36183616    QDateTime curtime = MythDate::current();
    3619     foreach (auto enc, *m_tvList)
     3617    for (auto enc : qAsConst(*m_tvList))
    36203618    {
    36213619        if (setWakingStatus && (enc->GetHostName() == slaveHostname))
    36223620            enc->SetSleepStatus(sStatus_Waking);
    void Scheduler::WakeUpSlaves(void) 
    36403638
    36413639    QStringList SlavesThatCanWake;
    36423640    QString thisSlave;
    3643     foreach (auto enc, *m_tvList)
     3641    for (auto enc : qAsConst(*m_tvList))
    36443642    {
    36453643        if (enc->IsLocal())
    36463644            continue;
    void Scheduler::AddNewRecords(void) 
    43144312    RecList tmpList;
    43154313
    43164314    QMap<int, bool> cardMap;
    4317     foreach (auto enc, *m_tvList)
     4315    for (auto enc : qAsConst(*m_tvList))
    43184316    {
    43194317        if (enc->IsConnected() || enc->IsAsleep())
    43204318            cardMap[enc->GetInputID()] = true;
    int Scheduler::FillRecordingDir( 
    54475445                        QString backuppath = expire->GetPathname();
    54485446                        ProgramInfo *programinfo = expire;
    54495447                        bool foundSlave = false;
    5450 
    5451                         foreach (auto & enc, *m_tvList)
     5448                        for (auto enc : qAsConst(*m_tvList))
    54525449                        {
    54535450                            if (enc->GetHostName() ==
    54545451                                programinfo->GetHostname())
    void Scheduler::SchedLiveTV(void) 
    56065603        return;
    56075604
    56085605    // Build a list of active livetv programs
    5609     foreach (auto enc, *m_tvList)
     5606    for (auto enc : qAsConst(*m_tvList))
    56105607    {
    56115608        if (kState_WatchingLiveTV != enc->GetState())
    56125609            continue;
  • mythtv/programs/mythbackend/services/dvr.cpp

    diff --git a/mythtv/programs/mythbackend/services/dvr.cpp b/mythtv/programs/mythbackend/services/dvr.cpp
    index 91f47b7c19..dd90d8bd62 100644
    a b DTC::EncoderList* Dvr::GetEncoderList() 
    680680
    681681    QReadLocker tvlocker(&TVRec::s_inputsLock);
    682682    QList<InputInfo> inputInfoList = CardUtil::GetAllInputInfo();
    683     foreach (auto elink, tvList)
     683    for (auto elink : qAsConst(tvList))
    684684    {
    685685        if (elink != nullptr)
    686686        {