From 6dad40fe443abef9fd6ae6a2d10f9f64f64f2bf8 Mon Sep 17 00:00:00 2001 From: Klaas de Waal Date: Wed, 1 Jan 2025 17:18:26 +0100 Subject: [PATCH] IPTV HLS Add channels in ascending order Add the IPTV channels in ascending numerical channel number order. In the QMap the order is based on channel number as string which is not the same unless all channel numbers have the same number of digits. Refs #936 --- .../channelscan/iptvchannelfetcher.cpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/mythtv/libs/libmythtv/channelscan/iptvchannelfetcher.cpp b/mythtv/libs/libmythtv/channelscan/iptvchannelfetcher.cpp index 1644a6401fd..e358ab5fcd7 100644 --- a/mythtv/libs/libmythtv/channelscan/iptvchannelfetcher.cpp +++ b/mythtv/libs/libmythtv/channelscan/iptvchannelfetcher.cpp @@ -155,9 +155,26 @@ void IPTVChannelFetcher::run(void) if (!m_isMpts) { - fbox_chan_map_t::const_iterator it = m_channels.cbegin(); - for (uint i = 1; it != m_channels.cend(); ++it, ++i) + // Sort channels in ascending channel number order + std::vector acno (m_channels.size()); { + fbox_chan_map_t::const_iterator it = m_channels.cbegin(); + for (uint i = 0; it != m_channels.cend(); ++it, ++i) + { + acno[i] = it; + } + std::sort(acno.begin(), acno.end(), + [] (fbox_chan_map_t::const_iterator s1, fbox_chan_map_t::const_iterator s2) -> bool + { + return s1.key().toInt() < s2.key().toInt(); + } + ); + } + + // Insert channels in ascending channel number order + for (uint i = 0; i < acno.size(); ++i) + { + fbox_chan_map_t::const_iterator it = acno[i]; const QString& channum = it.key(); QString name = (*it).m_name; QString xmltvid = (*it).m_xmltvid.isEmpty() ? "" : (*it).m_xmltvid;