fix potential context npe

This commit is contained in:
王劲鹏 2021-04-26 22:11:56 +08:00 committed by osborn
parent 0a7b66aeb3
commit c79362188a

View File

@ -11,8 +11,17 @@ DoricBridgeExtension::DoricBridgeExtension(QObject *parent) : QObject(parent) {}
void DoricBridgeExtension::callNative(QString contextId, QString module, void DoricBridgeExtension::callNative(QString contextId, QString module,
QString methodName, QString callbackId, QString methodName, QString callbackId,
QString argument) { QString argument) {
qDebug() << "contextId: " + contextId << "module: " + module
<< "methodName: " + methodName << "callbackId: " + callbackId
<< "jsValue: " + argument;
DoricContext *context = DoricContext *context =
DoricContextManager::getInstance()->getContext(contextId); DoricContextManager::getInstance()->getContext(contextId);
if (context == nullptr) {
qCritical() << "cannot find context: " + contextId;
return;
}
bool classRegistered = bool classRegistered =
context->getDriver()->getRegistry()->acquirePluginInfo(module); context->getDriver()->getRegistry()->acquirePluginInfo(module);
if (classRegistered) { if (classRegistered) {
@ -22,7 +31,4 @@ void DoricBridgeExtension::callNative(QString contextId, QString module,
Q_ARG(QString, argument), Q_ARG(QString, argument),
Q_ARG(QString, callbackId)); Q_ARG(QString, callbackId));
} }
qDebug() << "contextId: " + contextId << "module: " + module
<< "methodName: " + methodName << "callbackId: " + callbackId
<< "jsValue: " + argument;
} }