From f93f5eaf59032b728546ba5ab3afbb80126a0698 Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:19:32 +0100 Subject: [PATCH] Cleanup CPVRGUIProgressHandler: Get rid of some unneeded narrowing casts. --- xbmc/pvr/addons/PVRClients.cpp | 12 +++++------- xbmc/pvr/epg/EpgContainer.cpp | 6 +++--- xbmc/pvr/guilib/PVRGUIChannelIconUpdater.cpp | 5 ++--- xbmc/pvr/guilib/PVRGUIProgressHandler.cpp | 14 +++++++------- xbmc/pvr/guilib/PVRGUIProgressHandler.h | 8 ++++---- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/xbmc/pvr/addons/PVRClients.cpp b/xbmc/pvr/addons/PVRClients.cpp index 0d540134728ff..c615cbb679882 100644 --- a/xbmc/pvr/addons/PVRClients.cpp +++ b/xbmc/pvr/addons/PVRClients.cpp @@ -167,12 +167,11 @@ void CPVRClients::UpdateClients( auto progressHandler = std::make_unique( g_localizeStrings.Get(19239)); // Creating PVR clients - unsigned int i = 0; + size_t i = 0; for (const auto& client : clientsToCreate) { - progressHandler->UpdateProgress( - client->Name(), i++, - static_cast(clientsToCreate.size() + clientsToReCreate.size())); + progressHandler->UpdateProgress(client->Name(), i++, + clientsToCreate.size() + clientsToReCreate.size()); const ADDON_STATUS status = client->Create(); @@ -192,9 +191,8 @@ void CPVRClients::UpdateClients( for (const auto& clientInfo : clientsToReCreate) { - progressHandler->UpdateProgress( - clientInfo.second, i++, - static_cast(clientsToCreate.size() + clientsToReCreate.size())); + progressHandler->UpdateProgress(clientInfo.second, i++, + clientsToCreate.size() + clientsToReCreate.size()); // stop and recreate client StopClient(clientInfo.first, true /* restart */); diff --git a/xbmc/pvr/epg/EpgContainer.cpp b/xbmc/pvr/epg/EpgContainer.cpp index d2d744401b9d3..af6d58ca916ba 100644 --- a/xbmc/pvr/epg/EpgContainer.cpp +++ b/xbmc/pvr/epg/EpgContainer.cpp @@ -733,7 +733,6 @@ bool CPVREpgContainer::UpdateEPG(bool bOnlyPending /* = false */) std::vector> invalidTables; - unsigned int iCounter = 0; const std::shared_ptr database = GetEpgDatabase(); m_critSection.lock(); @@ -745,6 +744,7 @@ bool CPVREpgContainer::UpdateEPG(bool bOnlyPending /* = false */) progressHandler = std::make_unique( g_localizeStrings.Get(19004)); // Loading programme guide + size_t counter = 0; for (const auto& epgEntry : epgsToUpdate) { if (InterruptUpdate()) @@ -758,8 +758,8 @@ bool CPVREpgContainer::UpdateEPG(bool bOnlyPending /* = false */) continue; if (progressHandler) - progressHandler->UpdateProgress(epg->GetChannelData()->ChannelName(), ++iCounter, - static_cast(epgsToUpdate.size())); + progressHandler->UpdateProgress(epg->GetChannelData()->ChannelName(), ++counter, + epgsToUpdate.size()); if ((!bOnlyPending || epg->UpdatePending()) && epg->Update(start, diff --git a/xbmc/pvr/guilib/PVRGUIChannelIconUpdater.cpp b/xbmc/pvr/guilib/PVRGUIChannelIconUpdater.cpp index 20f6114387a4c..567626818b9db 100644 --- a/xbmc/pvr/guilib/PVRGUIChannelIconUpdater.cpp +++ b/xbmc/pvr/guilib/PVRGUIChannelIconUpdater.cpp @@ -65,13 +65,12 @@ void CPVRGUIChannelIconUpdater::SearchAndUpdateMissingChannelIcons() const for (const auto& group : m_groups) { const std::vector> members = group->GetMembers(); - int channelIndex = 0; + size_t channelIndex = 0; for (const auto& member : members) { const std::shared_ptr channel = member->Channel(); - progressHandler->UpdateProgress(channel->ChannelName(), channelIndex++, - static_cast(members.size())); + progressHandler->UpdateProgress(channel->ChannelName(), channelIndex++, members.size()); // skip if an icon is already set and exists if (CFileUtils::Exists(channel->IconPath())) diff --git a/xbmc/pvr/guilib/PVRGUIProgressHandler.cpp b/xbmc/pvr/guilib/PVRGUIProgressHandler.cpp index 791a613bfc805..4f8ac00cce37f 100644 --- a/xbmc/pvr/guilib/PVRGUIProgressHandler.cpp +++ b/xbmc/pvr/guilib/PVRGUIProgressHandler.cpp @@ -43,15 +43,15 @@ void CPVRGUIProgressHandler::UpdateProgress(const std::string& strText, float fP } } -void CPVRGUIProgressHandler::UpdateProgress(const std::string& strText, - unsigned int iCurrent, - unsigned int iMax) +void CPVRGUIProgressHandler::UpdateProgress(const std::string& text, + size_t currentValue, + size_t maxValue) { - float fPercentage = (iCurrent * 100.0f) / iMax; - if (!std::isnan(fPercentage)) - fPercentage = std::min(100.0f, fPercentage); + float percentage = (currentValue * 100.0f) / maxValue; + if (!std::isnan(percentage)) + percentage = std::min(100.0f, percentage); - UpdateProgress(strText, fPercentage); + UpdateProgress(text, percentage); } void CPVRGUIProgressHandler::Process() diff --git a/xbmc/pvr/guilib/PVRGUIProgressHandler.h b/xbmc/pvr/guilib/PVRGUIProgressHandler.h index 5c3aea1ecd723..468e7833893c4 100644 --- a/xbmc/pvr/guilib/PVRGUIProgressHandler.h +++ b/xbmc/pvr/guilib/PVRGUIProgressHandler.h @@ -37,11 +37,11 @@ namespace PVR /*! * @brief Update the progress dialogs's content. - * @param strText The new progress text. - * @param iCurrent The new current progress value, must be less or equal iMax. - * @param iMax The new maximum progress value, must be greater or equal iCurrent. + * @param text The new progress text. + * @param currentValue The new current progress value, must be less or equal iMax. + * @param maxValue The new maximum progress value, must be greater or equal iCurrent. */ - void UpdateProgress(const std::string& strText, unsigned int iCurrent, unsigned int iMax); + void UpdateProgress(const std::string& text, size_t currentValue, size_t maxValue); protected: // CThread implementation