From 1d8b0b22184b096a6f4dce986e8aada0a482ab34 Mon Sep 17 00:00:00 2001
From: David Hampton <mythtv@love2code.net>
Date: Mon, 24 Nov 2025 21:12:44 -0500
Subject: [PATCH] Fix Qt6 compilation errors in qstring.h.

The complicated code in Qt6 to determine the type of an argument being
passed to QString::arg seems to have run afoul of changes to
libstdc++; changes similar to those the MythTV code fixed in
7c781b3860.  While trying to determine the type of a variable
(specifically an instance of a class), Qt6 checks to see if it can be
converted to an integer with an "operator int()" function and checks
to see if it can be converted to a string with a "toString()"
function.  On recently updated Fedora 43 and Rawhide systems, this
code is now throwing four fatal errors each time it tries to determine
if it can coerce a variable to a known type.  Its unclear if this is
because of an upgrade to Qt 6.10 or to libstdc++ 15.2.1.

Adding explicit calls to a "toInt()" function or explicitly casting
the variable to "int" isn't an elegant solution, but it solves the
compilation failures without having to wait for Qt to resolve the
problem.
---
 mythtv/libs/libmythtv/cardutil.cpp                     | 6 +++---
 mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp   | 6 +++---
 mythtv/libs/libmythtv/dtvconfparserhelpers.h           | 1 +
 mythtv/libs/libmythtv/dtvmultiplex.cpp                 | 2 +-
 mythtv/libs/libmythtv/recorders/dtvchannel.cpp         | 2 +-
 mythtv/libs/libmythtv/recorders/satipchannel.cpp       | 2 +-
 mythtv/libs/libmythtv/recorders/satipstreamhandler.cpp | 2 +-
 mythtv/programs/mythfrontend/programinfocache.cpp      | 4 ++--
 8 files changed, 13 insertions(+), 12 deletions(-)

diff --git mythtv/libs/libmythtv/cardutil.cpp mythtv/libs/libmythtv/cardutil.cpp
index bbcbdc4d727..b6810efadbe 100644
--- mythtv/libs/libmythtv/cardutil.cpp
+++ mythtv/libs/libmythtv/cardutil.cpp
@@ -734,7 +734,7 @@ QString CardUtil::ProbeDVBType(const QString &device)
     ret = (type.toString() != "UNKNOWN") ? type.toString().toUpper() : ret;
 
     LOG(VB_GENERAL, LOG_DEBUG, LOC + QString("(%1) tuner type:%2 %3")
-        .arg(device).arg(type).arg(ret));
+        .arg(device).arg(type.toInt()).arg(ret));
 #endif // USING_DVB
 
     return ret;
@@ -839,7 +839,7 @@ DTVTunerType CardUtil::ConvertToTunerType(DTVModulationSystem delsys)
         default:
             LOG(VB_GENERAL, LOG_ERR, LOC +
                 QString("TODO Add to switch case delivery system:%2 %3")
-                    .arg(delsys).arg(delsys.toString()));
+                    .arg(delsys.toInt()).arg(delsys.toString()));
             break;
     }
 
@@ -936,7 +936,7 @@ DTVModulationSystem CardUtil::ProbeCurrentDeliverySystem([[maybe_unused]] const
     delsys = ProbeCurrentDeliverySystem(fd_frontend);
 
     LOG(VB_GENERAL, LOG_DEBUG, QString("CardUtil(%1): delsys:%2 %3")
-        .arg(device).arg(delsys).arg(delsys.toString()));
+        .arg(device).arg(delsys.toInt()).arg(delsys.toString()));
 
     close(fd_frontend);
 #endif
diff --git mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp
index 3be84c28414..01779c0b21d 100644
--- mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp
+++ mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp
@@ -1102,8 +1102,8 @@ bool ChannelScanSM::UpdateChannelInfo(bool wait_until_complete)
 
             LOG(VB_CHANSCAN, LOG_DEBUG, LOC +
                 QString("%1(%2) m_inputName: %3 ").arg(__FUNCTION__).arg(__LINE__).arg(m_inputName) +
-                QString("tunerType:%1 %2 ").arg(m_scanDTVTunerType).arg(m_scanDTVTunerType.toString()) +
-                QString("m_modSys:%1 %2 ").arg(item.m_tuning.m_modSys).arg(item.m_tuning.m_modSys.toString()) +
+                QString("tunerType:%1 %2 ").arg(m_scanDTVTunerType.toInt()).arg(m_scanDTVTunerType.toString()) +
+                QString("m_modSys:%1 %2 ").arg(item.m_tuning.m_modSys.toInt()).arg(item.m_tuning.m_modSys.toString()) +
                 QString("m_dvbt2Tried:%1").arg(m_dvbt2Tried));
 
             m_channelList << ChannelListItem(m_current, m_currentInfo);
@@ -2598,7 +2598,7 @@ bool ChannelScanSM::AddToList(uint mplexid)
 
     LOG(VB_CHANSCAN, LOG_DEBUG, LOC +
         QString("tunertype:%1 %2 sourceid:%3 sistandard:%4 fn:'%5' mplexid:%6")
-            .arg(tt).arg(tt.toString()).arg(sourceid).arg(sistandard, fn).arg(mplexid));
+            .arg(tt.toInt()).arg(tt.toString()).arg(sourceid).arg(sistandard, fn).arg(mplexid));
 
     if (item.m_tuning.FillFromDB(tt, mplexid))
     {
diff --git mythtv/libs/libmythtv/dtvconfparserhelpers.h mythtv/libs/libmythtv/dtvconfparserhelpers.h
index f72dc51fe91..8bbee2c6296 100644
--- mythtv/libs/libmythtv/dtvconfparserhelpers.h
+++ mythtv/libs/libmythtv/dtvconfparserhelpers.h
@@ -62,6 +62,7 @@ class DTVParamHelper
     DTVParamHelper &operator=(int _value) { m_value = _value; return *this; }
 
     operator int()                const { return m_value;        }
+    int  toInt()                  const { return m_value;        }
     bool operator==(const int v)  const { return m_value == v;   }
     bool operator!=(const int v)  const { return m_value != v;   }
 
diff --git mythtv/libs/libmythtv/dtvmultiplex.cpp mythtv/libs/libmythtv/dtvmultiplex.cpp
index ffefa363fbb..10af5cff06d 100644
--- mythtv/libs/libmythtv/dtvmultiplex.cpp
+++ mythtv/libs/libmythtv/dtvmultiplex.cpp
@@ -495,7 +495,7 @@ bool DTVMultiplex::ParseTuningParams(
 
     LOG(VB_GENERAL, LOG_ERR, LOC +
         QString("ParseTuningParams -- Unknown tuner type = 0x%1")
-        .arg(type,0,16,QChar('0')));
+        .arg(type.toInt(),0,16,QChar('0')));
 
     return false;
 }
diff --git mythtv/libs/libmythtv/recorders/dtvchannel.cpp mythtv/libs/libmythtv/recorders/dtvchannel.cpp
index d32e741b47b..57fc8cc6097 100644
--- mythtv/libs/libmythtv/recorders/dtvchannel.cpp
+++ mythtv/libs/libmythtv/recorders/dtvchannel.cpp
@@ -295,7 +295,7 @@ bool DTVChannel::SetChannelByString(const QString &channum)
             {
                 LOG(VB_GENERAL, LOG_DEBUG, loc +
                     QString("Initialize multiplex options m_tunerType:%1 mplexid:%2")
-                        .arg(m_tunerType).arg(mplexid));
+                        .arg(m_tunerType.toInt()).arg(mplexid));
 
                 // Try to fix any problems with the multiplex
                 CheckOptions(tuning);
diff --git mythtv/libs/libmythtv/recorders/satipchannel.cpp mythtv/libs/libmythtv/recorders/satipchannel.cpp
index 8a3157c8aa0..14cafd31834 100644
--- mythtv/libs/libmythtv/recorders/satipchannel.cpp
+++ mythtv/libs/libmythtv/recorders/satipchannel.cpp
@@ -49,7 +49,7 @@ bool SatIPChannel::Open(void)
     m_tunerType = SatIP::toTunerType(m_device);
 
     LOG(VB_CHANNEL, LOG_DEBUG, LOC + QString("Open(%1) m_tunerType:%2 %3")
-        .arg(m_device).arg(m_tunerType).arg(m_tunerType.toString()));
+        .arg(m_device).arg(m_tunerType.toInt()).arg(m_tunerType.toString()));
 
     if (!InitializeInput())
     {
diff --git mythtv/libs/libmythtv/recorders/satipstreamhandler.cpp mythtv/libs/libmythtv/recorders/satipstreamhandler.cpp
index 873d21b0590..5a673f547ea 100644
--- mythtv/libs/libmythtv/recorders/satipstreamhandler.cpp
+++ mythtv/libs/libmythtv/recorders/satipstreamhandler.cpp
@@ -393,7 +393,7 @@ bool SatIPStreamHandler::Tune(const DTVMultiplex &tuning)
     }
     else
     {
-        LOG(VB_RECORD, LOG_ERR, LOC + QString("Unhandled m_tunerType %1 %2").arg(m_tunerType).arg(m_tunerType.toString()));
+        LOG(VB_RECORD, LOG_ERR, LOC + QString("Unhandled m_tunerType %1 %2").arg(m_tunerType.toInt()).arg(m_tunerType.toString()));
         return false;
     }
 
diff --git mythtv/programs/mythfrontend/programinfocache.cpp mythtv/programs/mythfrontend/programinfocache.cpp
index 41c12f7e09b..ebecf0d0e78 100644
--- mythtv/programs/mythfrontend/programinfocache.cpp
+++ mythtv/programs/mythfrontend/programinfocache.cpp
@@ -232,7 +232,7 @@ ProgramInfoCache::UpdateStates ProgramInfoCache::Update(const ProgramInfo &pginf
     }
 
     LOG(VB_GUI, LOG_DEBUG, QString("Pg %1 %2 update state %3")
-        .arg(recordingId).arg(pg.GetTitle()).arg(flags));
+        .arg(recordingId).arg(pg.GetTitle()).arg(int(flags)));
     return flags;
 }
 
@@ -269,7 +269,7 @@ void ProgramInfoCache::UpdateFileSize(uint recordingID, uint64_t filesize,
     if (flags & PIC_MARK_CHANGED)
         pg->m_previewUpdate = pg->GetBookmarkUpdate();
 
-    QString mesg = QString("UPDATE_UI_ITEM %1 %2").arg(recordingID).arg(flags);
+    QString mesg = QString("UPDATE_UI_ITEM %1 %2").arg(recordingID).arg(int(flags));
     QCoreApplication::postEvent(m_listener, new MythEvent(mesg));
 
     LOG(VB_GUI, LOG_DEBUG, mesg);
