mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 01:03:08 +00:00
!48281 【mediaQuery】【补充】多实例场景添加ContainerScope保护
Merge pull request !48281 from 冯纪拓/add-1
This commit is contained in:
commit
7c1900a76e
@ -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