openmw: fix build with Qt 6.10

This commit is contained in:
Sirius902
2025-10-25 11:10:28 -07:00
parent c1a2638df6
commit c7db3c41e6
2 changed files with 128 additions and 0 deletions
@@ -0,0 +1,122 @@
From 0de42e9a1640e74b2c94ce16ecaf7367ece5f4b0 Mon Sep 17 00:00:00 2001
From: elsid <elsid.mail@gmail.com>
Date: Sun, 5 Oct 2025 23:40:17 +0200
Subject: [PATCH] Do not implicitly convert QByteArray to const char*
Operators supporting this conversion can be disabled via
QT_NO_CAST_FROM_BYTEARRAY breaking the build. For example:
https://koschei.fedoraproject.org//package/openmw
https://kojipkgs.fedoraproject.org/work/tasks/5096/137735096/build.log
Backported to OpenMW 0.49.x
Co-authored-by: Sirius902 <10891979+Sirius902@users.noreply.github.com>
---
apps/opencs/model/world/nestedtableproxymodel.cpp | 4 +++-
apps/opencs/view/world/util.cpp | 5 +++--
components/files/qtconversion.cpp | 11 ++++++-----
components/vfs/qtconversion.cpp | 11 ++++++-----
4 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/apps/opencs/model/world/nestedtableproxymodel.cpp b/apps/opencs/model/world/nestedtableproxymodel.cpp
index f542ce4def..5278710e4a 100644
--- a/apps/opencs/model/world/nestedtableproxymodel.cpp
+++ b/apps/opencs/model/world/nestedtableproxymodel.cpp
@@ -13,7 +13,9 @@ CSMWorld::NestedTableProxyModel::NestedTableProxyModel(
{
const int parentRow = parent.row();
- mId = std::string(parentModel->index(parentRow, 0).data().toString().toUtf8());
+ const QByteArray utf8 = parentModel->index(parentRow, 0).data().toString().toUtf8();
+
+ mId = std::string(utf8.constData(), utf8.size());
QAbstractProxyModel::setSourceModel(parentModel);
diff --git a/apps/opencs/view/world/util.cpp b/apps/opencs/view/world/util.cpp
index dfb587cd96..5fd32d78b4 100644
--- a/apps/opencs/view/world/util.cpp
+++ b/apps/opencs/view/world/util.cpp
@@ -363,11 +363,12 @@ void CSVWorld::CommandDelegate::setEditorData(QWidget* editor, const QModelIndex
{
if (!variant.isValid())
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- variant = QVariant(editor->property(n).metaType(), (const void*)nullptr);
+ variant = QVariant(editor->property(n.constData()).metaType(), (const void*)nullptr);
+ editor->setProperty(n.constData(), variant);
#else
variant = QVariant(editor->property(n).userType(), (const void*)nullptr);
+ editor->setProperty(n, variant);
#endif
- editor->setProperty(n, variant);
}
}
diff --git a/components/files/qtconversion.cpp b/components/files/qtconversion.cpp
index d56832cb78..ac7ca6ec8b 100644
--- a/components/files/qtconversion.cpp
+++ b/components/files/qtconversion.cpp
@@ -1,8 +1,9 @@
-
#include "qtconversion.hpp"
#include <components/misc/strings/conversion.hpp>
+#include <string_view>
+
QString Files::pathToQString(const std::filesystem::path& path)
{
const auto tmp = path.u8string();
@@ -17,12 +18,12 @@ QString Files::pathToQString(std::filesystem::path&& path)
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())));
}
diff --git a/components/vfs/qtconversion.cpp b/components/vfs/qtconversion.cpp
index 472e3dd0b4..fc8a0fb78e 100644
--- a/components/vfs/qtconversion.cpp
+++ b/components/vfs/qtconversion.cpp
@@ -1,8 +1,9 @@
-
#include "qtconversion.hpp"
#include <components/misc/strings/conversion.hpp>
+#include <string_view>
+
QString VFS::Path::normalizedToQString(NormalizedView path)
{
return QString::fromUtf8(path.value().data(), path.value().size());
@@ -15,12 +16,12 @@ QString VFS::Path::normalizedToQString(Normalized&& path)
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 = std::move(path).toUtf8();
+ return Normalized(std::string_view(tmp.constData(), tmp.size()));
}
--
2.51.0
+6
View File
@@ -85,6 +85,12 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-Eyjn3jPpo0d7XENg0Ea/3MN60lZBSUAMkz1UtTiIP80=";
};
patches = [
# https://gitlab.com/OpenMW/openmw/-/merge_requests/4941
# FIXME: Remove after next release
./0001-Do-not-implicitly-convert-QByteArray-to-const-char.patch
];
postPatch = ''
sed '1i#include <memory>' -i components/myguiplatform/myguidatamanager.cpp # gcc12
''