mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
【mediaQuery】【补充】多实例场景添加ContainerScope保护
Signed-off-by: fengjituo111 <fengjituo@huawei.com> Change-Id: Ie17c2dde63c352c211a39431d7a362f5f077ea5e
This commit is contained in:
parent
12b8a800cd
commit
b6124c1b01
@ -25,6 +25,7 @@ namespace OHOS::Ace::Napi {
|
||||
namespace {
|
||||
constexpr size_t STR_BUFFER_SIZE = 1024;
|
||||
constexpr int32_t TWO_ARGS = 2;
|
||||
constexpr int32_t DEFAULT_INSTANCE_ID = -1;
|
||||
}
|
||||
|
||||
using namespace OHOS::Ace::Framework;
|
||||
@ -168,7 +169,7 @@ public:
|
||||
napi_close_handle_scope(env, scope);
|
||||
return nullptr;
|
||||
}
|
||||
auto jsEngine = EngineHelper::GetEngine(listener->GetInstanceId());
|
||||
auto jsEngine = listener->GetJsEngine();
|
||||
if (!jsEngine) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -308,7 +309,7 @@ private:
|
||||
env_ = env;
|
||||
}
|
||||
napi_close_handle_scope(env, scope);
|
||||
auto jsEngine = EngineHelper::GetCurrentEngineSafely();
|
||||
auto jsEngine = GetJsEngine();
|
||||
if (!jsEngine) {
|
||||
return;
|
||||
}
|
||||
@ -327,6 +328,16 @@ private:
|
||||
return listener;
|
||||
}
|
||||
|
||||
RefPtr<Framework::JsEngine> GetJsEngine()
|
||||
{
|
||||
if (GetInstanceId() == DEFAULT_INSTANCE_ID) {
|
||||
TAG_LOGW(AceLogTag::ACE_MEDIA_QUERY, "matchMediaSync executes in non-UI context");
|
||||
return EngineHelper::GetCurrentEngineSafely();
|
||||
} else {
|
||||
return EngineHelper::GetEngine(GetInstanceId());
|
||||
}
|
||||
}
|
||||
|
||||
static size_t ParseArgs(napi_env& env, napi_callback_info& info, napi_value& thisVar, napi_value& cb)
|
||||
{
|
||||
const size_t argNum = 2;
|
||||
@ -357,7 +368,7 @@ private:
|
||||
|
||||
napi_env env_ = nullptr;
|
||||
std::list<napi_ref> cbList_;
|
||||
int32_t instanceId_;
|
||||
int32_t instanceId_ = DEFAULT_INSTANCE_ID;
|
||||
static std::set<std::unique_ptr<MediaQueryListener>>* delayDeleteListenerSets_;
|
||||
static napi_env delayDeleteEnv_;
|
||||
static std::set<napi_ref>* delayDeleteCallbacks_;
|
||||
|
Loading…
Reference in New Issue
Block a user