aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Sommerfeld <3226626+ksooo@users.noreply.github.com>2024-07-03 23:14:16 +0200
committerGitHub <noreply@github.com>2024-07-03 23:14:16 +0200
commit5020e13d6b1693688e0eb65131a235184e317adc (patch)
tree0a69d888ce78d75ef3eae7d6468a85edcd7a9a24
parent929b4d3f368aca5842b2b6294851bd2d111ae7f7 (diff)
parentfaac78cc53b00dcd9c888318fbdacbbfa665b9e6 (diff)
Merge pull request #25412 from ksooo/pvr-channelgroupscontainer-pointers
[PVR] CPVRChannelGroupsContainer: Replace raw pointers with std::shared_ptr
-rw-r--r--xbmc/interfaces/json-rpc/PVROperations.cpp5
-rw-r--r--xbmc/pvr/PVRPlaybackState.cpp6
-rw-r--r--xbmc/pvr/channels/PVRChannelGroups.cpp2
-rw-r--r--xbmc/pvr/channels/PVRChannelGroups.h2
-rw-r--r--xbmc/pvr/channels/PVRChannelGroupsContainer.cpp4
-rw-r--r--xbmc/pvr/channels/PVRChannelGroupsContainer.h10
-rw-r--r--xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp7
-rw-r--r--xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp4
-rw-r--r--xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp10
-rw-r--r--xbmc/pvr/filesystem/PVRGUIDirectory.cpp6
-rw-r--r--xbmc/pvr/guilib/PVRGUIActionsChannels.cpp4
-rw-r--r--xbmc/pvr/windows/GUIWindowPVRBase.cpp6
12 files changed, 35 insertions, 31 deletions
diff --git a/xbmc/interfaces/json-rpc/PVROperations.cpp b/xbmc/interfaces/json-rpc/PVROperations.cpp
index 07c8d93222..597d8b850d 100644
--- a/xbmc/interfaces/json-rpc/PVROperations.cpp
+++ b/xbmc/interfaces/json-rpc/PVROperations.cpp
@@ -65,8 +65,9 @@ JSONRPC_STATUS CPVROperations::GetChannelGroups(const std::string &method, ITran
if (!channelGroupContainer)
return FailedToExecute;
- CPVRChannelGroups *channelGroups = channelGroupContainer->Get(parameterObject["channeltype"].asString().compare("radio") == 0);
- if (channelGroups == NULL)
+ const std::shared_ptr<const CPVRChannelGroups> channelGroups{
+ channelGroupContainer->Get(parameterObject["channeltype"].asString().compare("radio") == 0)};
+ if (!channelGroups)
return FailedToExecute;
int start, end;
diff --git a/xbmc/pvr/PVRPlaybackState.cpp b/xbmc/pvr/PVRPlaybackState.cpp
index e29887ddce..4879a119a6 100644
--- a/xbmc/pvr/PVRPlaybackState.cpp
+++ b/xbmc/pvr/PVRPlaybackState.cpp
@@ -97,8 +97,8 @@ void CPVRPlaybackState::ReInit()
const std::shared_ptr<const CPVRChannelGroupsContainer> groups =
CServiceBroker::GetPVRManager().ChannelGroups();
- const CPVRChannelGroups* groupsTV = groups->GetTV();
- const CPVRChannelGroups* groupsRadio = groups->GetRadio();
+ const std::shared_ptr<const CPVRChannelGroups> groupsTV{groups->GetTV()};
+ const std::shared_ptr<const CPVRChannelGroups> groupsRadio{groups->GetRadio()};
m_activeGroupTV = groupsTV->GetLastOpenedGroup();
m_activeGroupRadio = groupsRadio->GetLastOpenedGroup();
@@ -555,7 +555,7 @@ namespace
std::shared_ptr<CPVRChannelGroup> GetFirstNonDeletedAndNonHiddenChannelGroup(
const std::shared_ptr<CPVRChannelGroupMember>& groupMember)
{
- CPVRChannelGroups* groups{
+ const std::shared_ptr<const CPVRChannelGroups> groups{
CServiceBroker::GetPVRManager().ChannelGroups()->Get(groupMember->IsRadio())};
if (groups)
{
diff --git a/xbmc/pvr/channels/PVRChannelGroups.cpp b/xbmc/pvr/channels/PVRChannelGroups.cpp
index c6539b7533..45008d81dd 100644
--- a/xbmc/pvr/channels/PVRChannelGroups.cpp
+++ b/xbmc/pvr/channels/PVRChannelGroups.cpp
@@ -239,7 +239,7 @@ std::shared_ptr<CPVRChannelGroupMember> CPVRChannelGroups::GetChannelGroupMember
}
std::vector<std::shared_ptr<CPVRChannelGroupMember>> CPVRChannelGroups::GetMembersAvailableForGroup(
- const std::shared_ptr<const CPVRChannelGroup>& group)
+ const std::shared_ptr<const CPVRChannelGroup>& group) const
{
std::vector<std::shared_ptr<CPVRChannelGroupMember>> result;
diff --git a/xbmc/pvr/channels/PVRChannelGroups.h b/xbmc/pvr/channels/PVRChannelGroups.h
index a3fc1fd754..8df9c5c525 100644
--- a/xbmc/pvr/channels/PVRChannelGroups.h
+++ b/xbmc/pvr/channels/PVRChannelGroups.h
@@ -97,7 +97,7 @@ public:
* @return The channel group members that could be added to the group
*/
std::vector<std::shared_ptr<CPVRChannelGroupMember>> GetMembersAvailableForGroup(
- const std::shared_ptr<const CPVRChannelGroup>& group);
+ const std::shared_ptr<const CPVRChannelGroup>& group) const;
/*!
* @brief Get a pointer to a channel group given its ID.
diff --git a/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp b/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp
index 04ff915c33..13f53da56e 100644
--- a/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp
+++ b/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp
@@ -27,8 +27,6 @@ CPVRChannelGroupsContainer::CPVRChannelGroupsContainer()
CPVRChannelGroupsContainer::~CPVRChannelGroupsContainer()
{
Unload();
- delete m_groupsRadio;
- delete m_groupsTV;
}
bool CPVRChannelGroupsContainer::Update(const std::vector<std::shared_ptr<CPVRClient>>& clients)
@@ -68,7 +66,7 @@ void CPVRChannelGroupsContainer::Unload()
m_groupsTV->Unload();
}
-CPVRChannelGroups* CPVRChannelGroupsContainer::Get(bool bRadio) const
+std::shared_ptr<CPVRChannelGroups> CPVRChannelGroupsContainer::Get(bool bRadio) const
{
return bRadio ? m_groupsRadio : m_groupsTV;
}
diff --git a/xbmc/pvr/channels/PVRChannelGroupsContainer.h b/xbmc/pvr/channels/PVRChannelGroupsContainer.h
index 8fb71c8e35..f0185f5331 100644
--- a/xbmc/pvr/channels/PVRChannelGroupsContainer.h
+++ b/xbmc/pvr/channels/PVRChannelGroupsContainer.h
@@ -60,20 +60,20 @@ public:
* @brief Get the TV channel groups.
* @return The TV channel groups.
*/
- CPVRChannelGroups* GetTV() const { return Get(false); }
+ std::shared_ptr<CPVRChannelGroups> GetTV() const { return Get(false); }
/*!
* @brief Get the radio channel groups.
* @return The radio channel groups.
*/
- CPVRChannelGroups* GetRadio() const { return Get(true); }
+ std::shared_ptr<CPVRChannelGroups> GetRadio() const { return Get(true); }
/*!
* @brief Get the radio or TV channel groups.
* @param bRadio If true, get the radio channel groups. Get the TV channel groups otherwise.
* @return The requested groups.
*/
- CPVRChannelGroups* Get(bool bRadio) const;
+ std::shared_ptr<CPVRChannelGroups> Get(bool bRadio) const;
/*!
* @brief Get the group containing all TV channels.
@@ -169,8 +169,8 @@ private:
*/
bool LoadFromDatabase(const std::vector<std::shared_ptr<CPVRClient>>& clients);
- CPVRChannelGroups* m_groupsRadio; /*!< all radio channel groups */
- CPVRChannelGroups* m_groupsTV; /*!< all TV channel groups */
+ std::shared_ptr<CPVRChannelGroups> m_groupsRadio; /*!< all radio channel groups */
+ std::shared_ptr<CPVRChannelGroups> m_groupsTV; /*!< all TV channel groups */
CCriticalSection m_critSection;
bool m_bIsUpdating = false;
};
diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp
index d6ed495ab1..ad9ae3e50a 100644
--- a/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp
+++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp
@@ -771,8 +771,8 @@ bool CGUIDialogPVRChannelManager::OnContextButton(int itemNumber, CONTEXT_BUTTON
PVR_ERROR ret = client->DeleteChannel(channel);
if (ret == PVR_ERROR_NO_ERROR)
{
- CPVRChannelGroups* groups =
- CServiceBroker::GetPVRManager().ChannelGroups()->Get(m_bIsRadio);
+ const std::shared_ptr<CPVRChannelGroups> groups{
+ CServiceBroker::GetPVRManager().ChannelGroups()->Get(m_bIsRadio)};
if (groups)
{
groups->UpdateFromClients({});
@@ -1081,7 +1081,8 @@ void CGUIDialogPVRChannelManager::SaveList()
group->SortAndRenumber();
- auto channelGroups = CServiceBroker::GetPVRManager().ChannelGroups()->Get(m_bIsRadio);
+ const std::shared_ptr<CPVRChannelGroups> channelGroups{
+ CServiceBroker::GetPVRManager().ChannelGroups()->Get(m_bIsRadio)};
channelGroups->UpdateChannelNumbersFromAllChannelsGroup();
channelGroups->PersistAll();
pDlgProgress->Close();
diff --git a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp
index c349bd0623..36ed331683 100644
--- a/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp
+++ b/xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp
@@ -133,8 +133,8 @@ bool CGUIDialogPVRChannelsOSD::OnAction(const CAction& action)
SaveControlStates();
// switch to next or previous group
- const CPVRChannelGroups* groups =
- CServiceBroker::GetPVRManager().ChannelGroups()->Get(m_group->IsRadio());
+ const std::shared_ptr<const CPVRChannelGroups> groups{
+ CServiceBroker::GetPVRManager().ChannelGroups()->Get(m_group->IsRadio())};
const std::shared_ptr<CPVRChannelGroup> nextGroup = action.GetID() == ACTION_NEXT_CHANNELGROUP
? groups->GetNextGroup(*m_group)
: groups->GetPreviousGroup(*m_group);
diff --git a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp
index 17c788aea8..32bc313d67 100644
--- a/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp
+++ b/xbmc/pvr/dialogs/GUIDialogPVRGroupManager.cpp
@@ -161,7 +161,8 @@ bool CGUIDialogPVRGroupManager::ActionButtonNewGroup(const CGUIMessage& message)
if (!strGroupName.empty())
{
// add the group if it doesn't already exist
- CPVRChannelGroups* groups{CServiceBroker::GetPVRManager().ChannelGroups()->Get(m_bIsRadio)};
+ const std::shared_ptr<CPVRChannelGroups> groups{
+ CServiceBroker::GetPVRManager().ChannelGroups()->Get(m_bIsRadio)};
const auto group = groups->AddGroup(strGroupName);
if (group)
{
@@ -653,7 +654,8 @@ void CGUIDialogPVRGroupManager::Update()
m_groupMembers->Add(std::make_shared<CFileItem>(groupMember));
}
- CPVRChannelGroups* groups{CServiceBroker::GetPVRManager().ChannelGroups()->Get(m_bIsRadio)};
+ const std::shared_ptr<const CPVRChannelGroups> groups{
+ CServiceBroker::GetPVRManager().ChannelGroups()->Get(m_bIsRadio)};
const auto availableMembers = groups->GetMembersAvailableForGroup(m_selectedGroup);
for (const auto& groupMember : availableMembers)
@@ -685,8 +687,8 @@ void CGUIDialogPVRGroupManager::Clear()
void CGUIDialogPVRGroupManager::ClearGroupThumbnails(const CFileItem& changedItem)
{
- const CPVRChannelGroups* groups{CServiceBroker::GetPVRManager().ChannelGroups()->Get(m_bIsRadio)};
-
+ const std::shared_ptr<const CPVRChannelGroups> groups{
+ CServiceBroker::GetPVRManager().ChannelGroups()->Get(m_bIsRadio)};
const std::shared_ptr<const CPVRChannelGroupMember> changedMember{
changedItem.GetPVRChannelGroupMemberInfoTag()};
if (changedMember)
diff --git a/xbmc/pvr/filesystem/PVRGUIDirectory.cpp b/xbmc/pvr/filesystem/PVRGUIDirectory.cpp
index 5bfa415dee..63341bd707 100644
--- a/xbmc/pvr/filesystem/PVRGUIDirectory.cpp
+++ b/xbmc/pvr/filesystem/PVRGUIDirectory.cpp
@@ -439,8 +439,8 @@ bool CPVRGUIDirectory::GetChannelGroupsDirectory(bool bRadio,
bool bExcludeHidden,
CFileItemList& results)
{
- const CPVRChannelGroups* channelGroups =
- CServiceBroker::GetPVRManager().ChannelGroups()->Get(bRadio);
+ const std::shared_ptr<const CPVRChannelGroups> channelGroups{
+ CServiceBroker::GetPVRManager().ChannelGroups()->Get(bRadio)};
if (channelGroups)
{
std::shared_ptr<CFileItem> item;
@@ -477,7 +477,7 @@ std::shared_ptr<CPVRChannelGroupMember> GetLastWatchedChannelGroupMember(
std::shared_ptr<CPVRChannelGroupMember> GetFirstMatchingGroupMember(
const std::shared_ptr<CPVRChannel>& channel)
{
- CPVRChannelGroups* groups{
+ const std::shared_ptr<const CPVRChannelGroups> groups{
CServiceBroker::GetPVRManager().ChannelGroups()->Get(channel->IsRadio())};
if (groups)
{
diff --git a/xbmc/pvr/guilib/PVRGUIActionsChannels.cpp b/xbmc/pvr/guilib/PVRGUIActionsChannels.cpp
index f13d331318..033ab0102b 100644
--- a/xbmc/pvr/guilib/PVRGUIActionsChannels.cpp
+++ b/xbmc/pvr/guilib/PVRGUIActionsChannels.cpp
@@ -125,8 +125,8 @@ void CPVRChannelSwitchingInputHandler::SwitchToChannel(const CPVRChannelNumber&
if (!groupMember)
{
// channel number present in any group?
- const CPVRChannelGroups* groupAccess =
- CServiceBroker::GetPVRManager().ChannelGroups()->Get(bRadio);
+ const std::shared_ptr<const CPVRChannelGroups> groupAccess{
+ CServiceBroker::GetPVRManager().ChannelGroups()->Get(bRadio)};
const std::vector<std::shared_ptr<CPVRChannelGroup>> groups =
groupAccess->GetMembers(true);
for (const auto& currentGroup : groups)
diff --git a/xbmc/pvr/windows/GUIWindowPVRBase.cpp b/xbmc/pvr/windows/GUIWindowPVRBase.cpp
index c6ef99abce..2af8531134 100644
--- a/xbmc/pvr/windows/GUIWindowPVRBase.cpp
+++ b/xbmc/pvr/windows/GUIWindowPVRBase.cpp
@@ -218,7 +218,8 @@ bool CGUIWindowPVRBase::ActivatePreviousChannelGroup()
const std::shared_ptr<const CPVRChannelGroup> channelGroup = GetChannelGroup();
if (channelGroup)
{
- const CPVRChannelGroups* groups = CServiceBroker::GetPVRManager().ChannelGroups()->Get(channelGroup->IsRadio());
+ const std::shared_ptr<const CPVRChannelGroups> groups{
+ CServiceBroker::GetPVRManager().ChannelGroups()->Get(channelGroup->IsRadio())};
if (groups)
{
SetChannelGroup(groups->GetPreviousGroup(*channelGroup));
@@ -233,7 +234,8 @@ bool CGUIWindowPVRBase::ActivateNextChannelGroup()
const std::shared_ptr<const CPVRChannelGroup> channelGroup = GetChannelGroup();
if (channelGroup)
{
- const CPVRChannelGroups* groups = CServiceBroker::GetPVRManager().ChannelGroups()->Get(channelGroup->IsRadio());
+ const std::shared_ptr<const CPVRChannelGroups> groups{
+ CServiceBroker::GetPVRManager().ChannelGroups()->Get(channelGroup->IsRadio())};
if (groups)
{
SetChannelGroup(groups->GetNextGroup(*channelGroup));