0001-Fix-builds-without-qml-module.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. From 4dee412aa655e1dc7f9e01869abcab47e0179422 Mon Sep 17 00:00:00 2001
  2. From: Julien Corjon <corjon.j@ecagroup.com>
  3. Date: Wed, 22 Jul 2015 09:24:04 +0200
  4. Subject: [PATCH] Fix builds without qml module
  5. When we build without qml module we cannot use QJSValue in qmetaobjectpublisher
  6. To prevent QJSValue inclusiion I use a preprocessor directive QT_HAVE_QML. This
  7. is probably not the best solution but I do not know any other QML directive.
  8. Upstream--Status: https://bugreports.qt.io/browse/QTBUG-47360
  9. Signed-off-by: Julien Corjon <corjon.j@ecagroup.com>
  10. ---
  11. src/webchannel/qmetaobjectpublisher.cpp | 4 ++++
  12. src/webchannel/webchannel.pro | 2 ++
  13. 2 files changed, 6 insertions(+)
  14. diff --git a/src/webchannel/qmetaobjectpublisher.cpp b/src/webchannel/qmetaobjectpublisher.cpp
  15. index 0cad569..b0e9652 100644
  16. --- a/src/webchannel/qmetaobjectpublisher.cpp
  17. +++ b/src/webchannel/qmetaobjectpublisher.cpp
  18. @@ -41,7 +41,9 @@
  19. #include <QDebug>
  20. #include <QJsonObject>
  21. #include <QJsonArray>
  22. +#ifdef QT_HAVE_QML
  23. #include <QJSValue>
  24. +#endif
  25. #include <QUuid>
  26. QT_BEGIN_NAMESPACE
  27. @@ -486,12 +488,14 @@ QJsonValue QMetaObjectPublisher::wrapResult(const QVariant &result, QWebChannelA
  28. if (!classInfo.isEmpty())
  29. objectInfo[KEY_DATA] = classInfo;
  30. return objectInfo;
  31. +#ifdef QT_HAVE_QML
  32. } else if (result.canConvert<QJSValue>()) {
  33. // Workaround for keeping QJSValues from QVariant.
  34. // Calling QJSValue::toVariant() converts JS-objects/arrays to QVariantMap/List
  35. // instead of stashing a QJSValue itself into a variant.
  36. // TODO: Improve QJSValue-QJsonValue conversion in Qt.
  37. return wrapResult(result.value<QJSValue>().toVariant(), transport, parentObjectId);
  38. +#endif
  39. } else if (result.canConvert<QVariantList>()) {
  40. // recurse and potentially wrap contents of the array
  41. return wrapList(result.toList(), transport);
  42. diff --git a/src/webchannel/webchannel.pro b/src/webchannel/webchannel.pro
  43. index eba8123..f476d6f 100644
  44. --- a/src/webchannel/webchannel.pro
  45. +++ b/src/webchannel/webchannel.pro
  46. @@ -30,6 +30,8 @@ SOURCES += \
  47. qtHaveModule(qml) {
  48. QT += qml
  49. + QMAKE_CXXFLAGS += "-DQT_HAVE_QML"
  50. +
  51. SOURCES += \
  52. qqmlwebchannel.cpp \
  53. qqmlwebchannelattached.cpp
  54. --
  55. 2.1.0