summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Corjon <corjon.j@ecagroup.com>2015-07-22 09:24:04 +0200
committerMilian Wolff <milian.wolff@kdab.com>2015-07-24 08:44:00 +0000
commit434edc50c6574c8289d6972b680323b47f38a3d4 (patch)
treeed5f5eb9b9f4a07b3d9e1a78bd5cabd292b73fcb
parent81449c0c804735b71ba2f225005482c7c0123dad (diff)
downloadqtwebchannel-434edc50c6574c8289d6972b680323b47f38a3d4.tar.gz
Fix builds without qml module
When we build without qml module we cannot use QJSValue in qmetaobjectpublisher Change-Id: I79d06d8cc6d43fdad57cbab17ebc1756444a7311 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
-rw-r--r--src/webchannel/qmetaobjectpublisher.cpp4
-rw-r--r--src/webchannel/webchannel.pro2
2 files changed, 6 insertions, 0 deletions
diff --git a/src/webchannel/qmetaobjectpublisher.cpp b/src/webchannel/qmetaobjectpublisher.cpp
index 42c95d2..61c5144 100644
--- a/src/webchannel/qmetaobjectpublisher.cpp
+++ b/src/webchannel/qmetaobjectpublisher.cpp
@@ -41,7 +41,9 @@
#include <QDebug>
#include <QJsonObject>
#include <QJsonArray>
+#ifdef QT_HAVE_QML
#include <QJSValue>
+#endif
#include <QUuid>
QT_BEGIN_NAMESPACE
@@ -489,12 +491,14 @@ QJsonValue QMetaObjectPublisher::wrapResult(const QVariant &result, QWebChannelA
objectInfo[KEY_DATA] = classInfo;
return objectInfo;
+#ifdef QT_HAVE_QML
} else if (result.canConvert<QJSValue>()) {
// Workaround for keeping QJSValues from QVariant.
// Calling QJSValue::toVariant() converts JS-objects/arrays to QVariantMap/List
// instead of stashing a QJSValue itself into a variant.
// TODO: Improve QJSValue-QJsonValue conversion in Qt.
return wrapResult(result.value<QJSValue>().toVariant(), transport, parentObjectId);
+#endif
} else if (result.canConvert<QVariantList>()) {
// recurse and potentially wrap contents of the array
return wrapList(result.toList(), transport);
diff --git a/src/webchannel/webchannel.pro b/src/webchannel/webchannel.pro
index eba8123..edaac13 100644
--- a/src/webchannel/webchannel.pro
+++ b/src/webchannel/webchannel.pro
@@ -30,6 +30,8 @@ SOURCES += \
qtHaveModule(qml) {
QT += qml
+ DEFINES += "QT_HAVE_QML"
+
SOURCES += \
qqmlwebchannel.cpp \
qqmlwebchannelattached.cpp