aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Bernardini <ponce@slackbuilds.org>2020-11-11 12:43:14 +0100
committerRobby Workman <rworkman@slackbuilds.org>2021-04-17 23:56:20 -0500
commitb94ff295f0cad68b208677a25eb113b610b419d9 (patch)
tree8bbdfc2686028285fdb815cbf1ed6c367c0cea2d
parent57f60acbbdd1cecabe20ef2b1da6092f13e6e8e6 (diff)
network/quassel-qt5: Patch for qt5 >= 5.14.x.
Signed-off-by: Matteo Bernardini <ponce@slackbuilds.org>
-rw-r--r--network/quassel-qt5/quassel-0.13.1-qt5.14.patch118
-rw-r--r--network/quassel-qt5/quassel-qt5.SlackBuild2
2 files changed, 120 insertions, 0 deletions
diff --git a/network/quassel-qt5/quassel-0.13.1-qt5.14.patch b/network/quassel-qt5/quassel-0.13.1-qt5.14.patch
new file mode 100644
index 0000000000000..f0305ea53ce76
--- /dev/null
+++ b/network/quassel-qt5/quassel-0.13.1-qt5.14.patch
@@ -0,0 +1,118 @@
+commit c90702bdbc43fc542d7df6d5ec4b321912ca0035
+Author: Manuel Nickschas <sputnick@quassel-irc.org>
+Date: Tue Jan 7 18:34:54 2020 +0100
+
+ common: Disable enum type stream operators for Qt >= 5.14
+
+ Starting from version 5.14, Qt provides stream operators for enum
+ types, which collide with the ones we ship in types.h. Disable
+ Quassel's stream operators when compiling against Qt 5.14 or later.
+
+ Add a unit test that ensures that enum serialization honors the width
+ of the underlying type.
+
+diff --git a/src/common/types.h b/src/common/types.h
+index 467d9fb2..c4b9f364 100644
+--- a/src/common/types.h
++++ b/src/common/types.h
+@@ -140,6 +140,7 @@ Q_DECLARE_METATYPE(QHostAddress)
+ typedef QList<MsgId> MsgIdList;
+ typedef QList<BufferId> BufferIdList;
+
++#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
+ /**
+ * Catch-all stream serialization operator for enum types.
+ *
+@@ -169,6 +170,7 @@ QDataStream &operator>>(QDataStream &in, T &value) {
+ value = static_cast<T>(v);
+ return in;
+ }
++#endif
+
+ // Exceptions
+
+diff --git a/src/common/typestest.cpp b/src/common/typestest.cpp
+new file mode 100644
+index 00000000..04031c29
+--- /dev/null
++++ b/src/common/typestest.cpp
+@@ -0,0 +1,79 @@
++/***************************************************************************
++ * Copyright (C) 2005-2020 by the Quassel Project *
++ * devel@quassel-irc.org *
++ * *
++ * This program is free software; you can redistribute it and/or modify *
++ * it under the terms of the GNU General Public License as published by *
++ * the Free Software Foundation; either version 2 of the License, or *
++ * (at your option) version 3. *
++ * *
++ * This program is distributed in the hope that it will be useful, *
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
++ * GNU General Public License for more details. *
++ * *
++ * You should have received a copy of the GNU General Public License *
++ * along with this program; if not, write to the *
++ * Free Software Foundation, Inc., *
++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
++ ***************************************************************************/
++
++#include <cstdint>
++
++#include <QByteArray>
++#include <QDataStream>
++#include <QObject>
++
++#include "testglobal.h"
++#include "types.h"
++
++using namespace ::testing;
++
++class EnumHolder
++{
++ Q_GADGET
++
++public:
++ enum class Enum16 : uint16_t {};
++ enum class Enum32 : uint32_t {};
++
++ enum class EnumQt16 : uint16_t {};
++ Q_ENUM(EnumQt16)
++ enum class EnumQt32 : uint32_t {};
++ Q_ENUM(EnumQt32)
++};
++
++// Verify that enums are (de)serialized as their underlying type
++TEST(TypesTest, enumSerialization)
++{
++ QByteArray data;
++ QDataStream out(&data, QIODevice::WriteOnly);
++
++ // Serialize
++ out << EnumHolder::Enum16(0xabcd);
++ ASSERT_THAT(data.size(), Eq(2));
++ out << EnumHolder::Enum32(0x123456);
++ ASSERT_THAT(data.size(), Eq(6));
++ out << EnumHolder::EnumQt16(0x4321);
++ ASSERT_THAT(data.size(), Eq(8));
++ out << EnumHolder::Enum32(0xfedcba);
++ ASSERT_THAT(data.size(), Eq(12));
++ ASSERT_THAT(out.status(), Eq(QDataStream::Status::Ok));
++
++ // Deserialize
++ QDataStream in(data);
++ EnumHolder::Enum16 enum16;
++ EnumHolder::Enum32 enum32;
++ EnumHolder::EnumQt16 enumQt16;
++ EnumHolder::EnumQt32 enumQt32;
++ in >> enum16 >> enum32 >> enumQt16 >> enumQt32;
++ ASSERT_THAT(in.status(), Eq(QDataStream::Status::Ok));
++ EXPECT_TRUE(in.atEnd());
++
++ EXPECT_THAT((int)enum16, Eq(0xabcd));
++ EXPECT_THAT((int)enum32, Eq(0x123456));
++ EXPECT_THAT((int)enumQt16, Eq(0x4321));
++ EXPECT_THAT((int)enumQt32, Eq(0xfedcba));
++}
++
++#include "typestest.moc"
diff --git a/network/quassel-qt5/quassel-qt5.SlackBuild b/network/quassel-qt5/quassel-qt5.SlackBuild
index c136a341d9ab2..72093342f6197 100644
--- a/network/quassel-qt5/quassel-qt5.SlackBuild
+++ b/network/quassel-qt5/quassel-qt5.SlackBuild
@@ -71,6 +71,8 @@ find -L . \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
+patch -p1 < $CWD/quassel-0.13.1-qt5.14.patch
+
mkdir -p build
cd build
cmake \