mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 09:12:41 +00:00
commit
53bcc0a734
@ -249,7 +249,9 @@ void ComponentObserver::Destroy(napi_env env)
|
||||
for (auto& drawitem : cbDrawList_) {
|
||||
napi_delete_reference(env, drawitem);
|
||||
}
|
||||
auto jsEngine = EngineHelper::GetCurrentEngineSafely();
|
||||
cbLayoutList_.clear();
|
||||
cbDrawList_.clear();
|
||||
auto jsEngine = weakEngine_.Upgrade();
|
||||
if (!jsEngine) {
|
||||
return;
|
||||
}
|
||||
@ -304,6 +306,7 @@ static napi_value JSCreateComponentObserver(napi_env env, napi_callback_info inf
|
||||
|
||||
jsEngine->RegisterLayoutInspectorCallback(observer->layoutEvent_, observer->componentId_);
|
||||
jsEngine->RegisterDrawInspectorCallback(observer->drawEvent_, observer->componentId_);
|
||||
observer->SetEngine(jsEngine);
|
||||
#if defined(PREVIEW)
|
||||
layoutCallback();
|
||||
drawCallback();
|
||||
|
@ -51,10 +51,15 @@ public:
|
||||
std::string componentId_;
|
||||
std::list<napi_ref> cbLayoutList_;
|
||||
std::list<napi_ref> cbDrawList_;
|
||||
void SetEngine(const RefPtr<Framework::JsEngine>& engine)
|
||||
{
|
||||
weakEngine_ = engine;
|
||||
}
|
||||
|
||||
private:
|
||||
void FunctionOn(napi_env& env, napi_value result, const char* funName);
|
||||
void FunctionOff(napi_env& env, napi_value result, const char* funName);
|
||||
WeakPtr<Framework::JsEngine> weakEngine_;
|
||||
};
|
||||
} // namespace OHOS::Ace::Napi
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user