From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: openKylinBot <openKylinBot@openkylin.top>
Date: Oct, 19 2026 23:44:56 +0000
Subject: [PATCH] Fix FTBFS with Qt 6.10: disambiguate QByteArray to string conversions

Description: Disambiguate the QByteArray -> string conversions in the Qt helpers
 Qt 6.10 added an implicit QByteArray -> std::string_view conversion operator, so
 passing the QByteArray returned by QString::toUtf8() to the overload sets used in
 these two files became ambiguous and the build fails:
 .
   components/files/qtconversion.cpp:21:70: error: call of overloaded
     'stringToU8String(const QByteArray&)' is ambiguous
   components/vfs/qtconversion.cpp:19:28: error: call of overloaded
     'Normalized(<brace-enclosed initializer list>)' is ambiguous
 .
 Both calls are disambiguated by building the std::string_view explicitly from the
 QByteArray data and size, which is exactly how the compiler resolved the calls
 before Qt 6.10 (the data, the length and therefore the resulting path/normalized
 string are unchanged).
 .
 The failure is caused by the Qt version in the build environment, not by the
 architecture: the arm64/loong64/riscv64 builders got qt6-base 6.10.2 and fail,
 while the amd64 builder got qt6-base 6.4.2 and built fine. The fix uses
 only Qt APIs available in both 6.4 and 6.10, so the old code path is not needed
 and no Qt version macro is required. Upstream 0.51.0 solved the same ambiguity in
 these files by constructing std::u16string/std::string_view explicitly.
Author: tangxiaofeng <tangxiaofeng@kylinos.cn>
Forwarded: not-needed
Last-Update: 2026-10-19

--- openmw-0.49.0.orig/components/files/qtconversion.cpp
+++ openmw-0.49.0/components/files/qtconversion.cpp
@@ -3,6 +3,13 @@
 
 #include <components/misc/strings/conversion.hpp>
 
+#include <string_view>
+
+// Qt 6.10 added an implicit QByteArray -> std::string_view conversion operator, so passing
+// the QByteArray returned by QString::toUtf8() to the Misc::StringUtils::stringToU8String()
+// overload set (const char* / std::string_view) is ambiguous. Construct the std::string_view
+// explicitly, which is how the compiler resolved the call before Qt 6.10.
+
 QString Files::pathToQString(const std::filesystem::path& path)
 {
     const auto tmp = path.u8string();
@@ -17,12 +24,12 @@ QString Files::pathToQString(std::filesy
 
 std::filesystem::path Files::pathFromQString(QStringView path)
 {
-    const auto tmp = path.toUtf8();
-    return std::filesystem::path{ Misc::StringUtils::stringToU8String(tmp) };
+    const QByteArray tmp = path.toUtf8();
+    return std::filesystem::path{ Misc::StringUtils::stringToU8String(std::string_view(tmp.constData(), tmp.size())) };
 }
 
 std::filesystem::path Files::pathFromQString(QString&& path)
 {
-    const auto tmp = path.toUtf8();
-    return std::filesystem::path{ Misc::StringUtils::stringToU8String(tmp) };
+    const QByteArray tmp = path.toUtf8();
+    return std::filesystem::path{ Misc::StringUtils::stringToU8String(std::string_view(tmp.constData(), tmp.size())) };
 }
--- openmw-0.49.0.orig/components/vfs/qtconversion.cpp
+++ openmw-0.49.0/components/vfs/qtconversion.cpp
@@ -3,6 +3,13 @@
 
 #include <components/misc/strings/conversion.hpp>
 
+#include <string_view>
+
+// Qt 6.10 added an implicit QByteArray -> std::string_view conversion operator, which makes
+// the direct-initialization of Normalized (const char* / std::string_view constructors)
+// ambiguous. Construct the std::string_view explicitly instead, which preserves the data
+// length and matches how the compiler resolved the call before Qt 6.10.
+
 QString VFS::Path::normalizedToQString(NormalizedView path)
 {
     return QString::fromUtf8(path.value().data(), path.value().size());
@@ -15,12 +22,12 @@ QString VFS::Path::normalizedToQString(N
 
 VFS::Path::Normalized VFS::Path::normalizedFromQString(QStringView path)
 {
-    const auto tmp = path.toUtf8();
-    return Normalized{ tmp };
+    const QByteArray tmp = path.toUtf8();
+    return Normalized(std::string_view(tmp.constData(), tmp.size()));
 }
 
 VFS::Path::Normalized VFS::Path::normalizedFromQString(QString&& path)
 {
-    const auto tmp = path.toUtf8();
-    return Normalized{ tmp };
+    const QByteArray tmp = path.toUtf8();
+    return Normalized(std::string_view(tmp.constData(), tmp.size()));
 }
