summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization
diff options
context:
space:
mode:
authorMichael Pyne <mpyne@kde.org>2018-07-04 11:36:14 -0400
committerMichael Pyne <mpyne@kde.org>2018-07-04 23:36:17 +0000
commit4b10298de54a7cacb5f25601f8e3ae5d233806d3 (patch)
tree738a7e3a9e864f5e509d67782dc3609ebeda075a /src/corelib/serialization
parent21ea8c05ffa719cd3342b4a1c02620b556f4ec7b (diff)
CBOR: Avoid conflicts with X11 #defines in our enums
Since the .cpp files in the implementation don't actually include the offending X11 headers they don't need the fix. This just adjusts the headers themselves to unbreak the namespace for just long enough to declare the right enums. Change-Id: If33757aa2289f8fe7b81836f9c08b0ad4592bc32 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization')
-rw-r--r--src/corelib/serialization/qcborcommon.h14
-rw-r--r--src/corelib/serialization/qcborstream.h11
-rw-r--r--src/corelib/serialization/qcborvalue.h11
3 files changed, 36 insertions, 0 deletions
diff --git a/src/corelib/serialization/qcborcommon.h b/src/corelib/serialization/qcborcommon.h
index 2c6d44657d..9661cd70bb 100644
--- a/src/corelib/serialization/qcborcommon.h
+++ b/src/corelib/serialization/qcborcommon.h
@@ -48,6 +48,13 @@
#pragma qt_class(QtCborCommon)
#endif
+/* X11 headers use these values too, but as defines */
+#if defined(False) && defined(True)
+# define QT_X11_DEFINES_FOUND 1
+# undef True
+# undef False
+#endif
+
QT_BEGIN_NAMESPACE
enum class QCborSimpleType : quint8 {
@@ -130,4 +137,11 @@ QT_END_NAMESPACE
Q_DECLARE_METATYPE(QCborTag)
+// To avoid changing namespace we need to reinstate defines, even though our .cpp
+// will then have to remove them again.
+#if defined(QT_X11_DEFINES_FOUND)
+# define True 1
+# define False 0
+#endif
+
#endif // QCBORSTREAM_H
diff --git a/src/corelib/serialization/qcborstream.h b/src/corelib/serialization/qcborstream.h
index 22f6a8218e..85acfd85ea 100644
--- a/src/corelib/serialization/qcborstream.h
+++ b/src/corelib/serialization/qcborstream.h
@@ -47,6 +47,12 @@
#include <QtCore/qstring.h>
#include <QtCore/qstringview.h>
+// See qcborcommon.h for why we check
+#if defined(QT_X11_DEFINES_FOUND)
+# undef True
+# undef False
+#endif
+
QT_BEGIN_NAMESPACE
class QIODevice;
@@ -253,4 +259,9 @@ private:
QT_END_NAMESPACE
+#if defined(QT_X11_DEFINES_FOUND)
+# define True 1
+# define False 0
+#endif
+
#endif // QCBORSTREAM_H
diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h
index b7280dd35f..8411830835 100644
--- a/src/corelib/serialization/qcborvalue.h
+++ b/src/corelib/serialization/qcborvalue.h
@@ -51,6 +51,12 @@
#include <QtCore/qvariant.h>
#include <QtCore/qvector.h>
+// See qcborcommon.h for why we check
+#if defined(QT_X11_DEFINES_FOUND)
+# undef True
+# undef False
+#endif
+
#if QT_HAS_INCLUDE(<compare>)
# include <compare>
#endif
@@ -438,4 +444,9 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborValue &v);
QT_END_NAMESPACE
+#if defined(QT_X11_DEFINES_FOUND)
+# define True 1
+# define False 0
+#endif
+
#endif // QCBORVALUE_H