Permalink
Browse files

[pvr] fixed - channel updates from the backend weren't forwarded prop…

…erly and numbering could become messed up after changes on the backend
  • Loading branch information...
1 parent a562e9d commit f679b31e72c2a30241597c5b2c1b903f19c3fbb8 @opdenkamp opdenkamp committed Oct 26, 2012
View
39 xbmc/pvr/channels/PVRChannelGroup.cpp
@@ -125,8 +125,7 @@ int CPVRChannelGroup::Load(void)
__FUNCTION__, Size() - iChannelCount, m_strGroupName.c_str());
}
- SortByChannelNumber();
- Renumber();
+ SortAndRenumber();
g_guiSettings.RegisterObserver(this);
m_bLoaded = true;
@@ -183,9 +182,6 @@ bool CPVRChannelGroup::MoveChannel(unsigned int iOldChannelNumber, unsigned int
bool bReturn(false);
CSingleLock lock(m_critSection);
- /* make sure the list is sorted by channel number */
- SortByChannelNumber();
-
/* old channel number out of range */
if (iOldChannelNumber > m_members.size())
return bReturn;
@@ -200,7 +196,7 @@ bool CPVRChannelGroup::MoveChannel(unsigned int iOldChannelNumber, unsigned int
m_members.insert(m_members.begin() + iNewChannelNumber - 1, entry);
/* renumber the list */
- Renumber();
+ SortAndRenumber();
m_bChanged = true;
@@ -279,6 +275,19 @@ struct sortByChannelNumber
}
};
+bool CPVRChannelGroup::SortAndRenumber(void)
+{
+ CSingleLock lock(m_critSection);
+ if (m_bUsingBackendChannelOrder)
+ SortByClientChannelNumber();
+ else
+ SortByChannelNumber();
+
+ bool bReturn = Renumber();
+ ResetChannelNumberCache();
+ return bReturn;
+}
+
void CPVRChannelGroup::SortByClientChannelNumber(void)
{
CSingleLock lock(m_critSection);
@@ -641,17 +650,14 @@ bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels)
if (bChanged)
{
- if (bUseBackendChannelNumbers)
- SortByClientChannelNumber();
-
/* renumber to make sure all channels have a channel number.
new channels were added at the back, so they'll get the highest numbers */
- bool bRenumbered = Renumber();
+ bool bRenumbered = SortAndRenumber();
SetChanged();
lock.Leave();
- NotifyObservers(HasNewChannels() || bRemoved || bRenumbered ? ObservableMessageChannelGroup : ObservableMessageChannelGroupReset);
+ NotifyObservers(HasNewChannels() || bRemoved || bRenumbered ? ObservableMessageChannelGroupReset : ObservableMessageChannelGroup);
bReturn = Persist();
}
@@ -749,13 +755,7 @@ bool CPVRChannelGroup::AddToGroup(CPVRChannel &channel, int iChannelNumber /* =
m_bChanged = true;
if (bSortAndRenumber)
- {
- if (m_bUsingBackendChannelOrder)
- SortByClientChannelNumber();
- else
- SortByChannelNumber();
- Renumber();
- }
+ SortAndRenumber();
// TODO notify observers
bReturn = true;
@@ -960,8 +960,7 @@ void CPVRChannelGroup::Notify(const Observable &obs, const ObservableMessage msg
{
CLog::Log(LOGDEBUG, "CPVRChannelGroup - %s - renumbering group '%s' to use the backend channel order and/or numbers",
__FUNCTION__, m_strGroupName.c_str());
- SortByClientChannelNumber();
- Renumber();
+ SortAndRenumber();
Persist();
}
}
View
20 xbmc/pvr/channels/PVRChannelGroup.h
@@ -214,14 +214,10 @@ namespace PVR
//@{
/*!
- * @brief Sort the current channel list by client channel number.
+ * @brief Sort the group and fix up channel numbers.
+ * @return True when numbering changed, false otherwise
*/
- void SortByClientChannelNumber(void);
-
- /*!
- * @brief Sort the current channel list by channel number.
- */
- void SortByChannelNumber(void);
+ bool SortAndRenumber(void);
//@}
@@ -424,6 +420,16 @@ namespace PVR
virtual bool Renumber(void);
/*!
+ * @brief Sort the current channel list by client channel number.
+ */
+ void SortByClientChannelNumber(void);
+
+ /*!
+ * @brief Sort the current channel list by channel number.
+ */
+ void SortByChannelNumber(void);
+
+ /*!
* @brief Get the previous or next channel in this group.
* @param channel The current channel.
* @param bChannelUp True to get the next channel, false to get the previous one.
View
8 xbmc/pvr/channels/PVRChannelGroupInternal.cpp
@@ -98,11 +98,7 @@ void CPVRChannelGroupInternal::UpdateFromClient(const CPVRChannel &channel, unsi
m_members.push_back(newMember);
m_bChanged = true;
- if (m_bUsingBackendChannelOrder)
- SortByClientChannelNumber();
- else
- SortByChannelNumber();
- Renumber();
+ SortAndRenumber();
}
}
@@ -181,7 +177,7 @@ bool CPVRChannelGroupInternal::RemoveFromGroup(const CPVRChannel &channel)
}
/* renumber this list */
- Renumber();
+ SortAndRenumber();
/* and persist */
return realChannel->Persist() &&
View
3 xbmc/pvr/dialogs/GUIDialogPVRChannelManager.cpp
@@ -816,9 +816,8 @@ void CGUIDialogPVRChannelManager::SaveList(void)
pDlgProgress->SetPercentage(iListPtr * 100 / m_channelItems->Size());
}
- group->SortByChannelNumber();
+ group->SortAndRenumber();
group->Persist();
- group->ResetChannelNumberCache();
m_bContainsChanges = false;
SetItemsUnchanged();
pDlgProgress->Close();
View
6 xbmc/pvr/windows/GUIWindowPVRChannels.cpp
@@ -171,7 +171,7 @@ void CGUIWindowPVRChannels::Notify(const Observable &obs, const ObservableMessag
else if (msg == ObservableMessageChannelGroupReset)
{
if (IsVisible())
- UpdateData(false);
+ UpdateData(true);
else
m_bUpdateRequired = true;
}
@@ -204,6 +204,8 @@ void CGUIWindowPVRChannels::UpdateData(bool bUpdateSelectedFile /* = true */)
/* lock the graphics context while updating */
CSingleLock graphicsLock(g_graphicsContext);
+ CPVRChannelGroupPtr selectedGroup = SelectedGroup();
+
m_iSelected = m_parent->m_viewControl.GetSelectedItem();
m_parent->m_viewControl.Clear();
m_parent->m_vecItems->Clear();
@@ -213,6 +215,8 @@ void CGUIWindowPVRChannels::UpdateData(bool bUpdateSelectedFile /* = true */)
if (!currentGroup)
return;
+ SetSelectedGroup(currentGroup);
+
CStdString strPath;
strPath.Format("pvr://channels/%s/%s/",
m_bRadio ? "radio" : "tv",

0 comments on commit f679b31

Please sign in to comment.