fix json value crash & timer not work

This commit is contained in:
王劲鹏
2021-04-06 17:58:23 +08:00
committed by osborn
parent fc0af6e992
commit c01bd1e98c
5 changed files with 36 additions and 22 deletions

View File

@@ -1,24 +1,29 @@
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include "../shader/DoricRootNode.h"
#include "DoricShaderPlugin.h"
void DoricShaderPlugin::render(QJsonObject *jsValue, QString callbackId) {
void DoricShaderPlugin::render(QString jsValueString, QString callbackId) {
getContext()->getDriver()->asyncCall(
[this, jsValue] {
[this, jsValueString] {
try {
QString viewId = jsValue->value("id").toString();
QJsonDocument document =
QJsonDocument::fromJson(jsValueString.toUtf8());
QJsonValue jsValue = document.object();
QString viewId = jsValue["id"].toString();
DoricRootNode *rootNode = getContext()->getRootNode();
if (rootNode->getId().isEmpty() &&
jsValue->value("type").toString() == "Root") {
jsValue["type"].toString() == "Root") {
rootNode->setId(viewId);
rootNode->blend(jsValue->value("props"));
rootNode->blend(jsValue["props"]);
} else {
DoricViewNode *viewNode = getContext()->targetViewNode(viewId);
if (viewNode != nullptr) {
viewNode->blend(jsValue->value("props"));
viewNode->blend(jsValue["props"]);
}
}
} catch (...) {

View File

@@ -11,7 +11,7 @@ class DoricShaderPlugin : public DoricNativePlugin {
public:
using DoricNativePlugin::DoricNativePlugin;
Q_INVOKABLE void render(QJsonObject *jsValue, QString callbackId);
Q_INVOKABLE void render(QString jsValueString, QString callbackId);
};
#endif // SHADERPLUGIN_H