Skip to content

Commit

Permalink
[qtmozembed] Fix JSON message serialization. Contributes to JB#37190
Browse files Browse the repository at this point in the history
  • Loading branch information
rainemak committed Dec 18, 2018
1 parent 33f4e6b commit 1a5ec17
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/qmozview_p.cpp
Expand Up @@ -739,10 +739,16 @@ char *QMozViewPrivate::RecvSyncMessage(const char16_t *aMessage, const char16_t

mViewIface->recvSyncMessage(message.get(), vdata, &response);

QJsonDocument respdoc = QJsonDocument::fromVariant(response.getMessage());
QByteArray array = respdoc.toJson();

LOGT("msg:%s, response:%s", message.get(), array.constData());
QVariant responseMessage = response.getMessage();
QJsonDocument responseDocument;
if (responseMessage.userType() == QMetaType::type("QJSValue")) {
// Qt 5.6 likes to pass a QJSValue
QJSValue jsValue = qvariant_cast<QJSValue>(responseMessage);
responseDocument = QJsonDocument::fromVariant(jsValue.toVariant());
} else {
responseDocument = QJsonDocument::fromVariant(responseMessage);
}
QByteArray array = responseDocument.toJson();
return strdup(array.constData());
}

Expand Down

0 comments on commit 1a5ec17

Please sign in to comment.