Signed-off-by: ma-shaoyin <mashaoyin1@huawei.com>

Changes to be committed:
This commit is contained in:
ma-shaoyin 2023-08-01 16:24:21 +08:00
parent 451f77ff1e
commit c626704cb2
2 changed files with 1 additions and 4 deletions

View File

@ -35,12 +35,10 @@ std::shared_ptr<PanelListenerImpl> PanelListenerImpl::GetInstance()
PanelListenerImpl::~PanelListenerImpl()
{
env_ = nullptr;
}
void PanelListenerImpl::SaveInfo(napi_env env, const std::string &type, napi_value callback, uint32_t windowId)
{
env_ = env;
std::shared_ptr<JSCallbackObject> cbObject =
std::make_shared<JSCallbackObject>(env, callback, std::this_thread::get_id());
auto result = callbacks_.Find(windowId);
@ -93,7 +91,7 @@ void PanelListenerImpl::OnPanelStatus(uint32_t windowId, bool isShow)
}
work->data = new (std::nothrow) UvEntry(callback.second);
uv_loop_s *loop = nullptr;
napi_get_uv_event_loop(env_, &loop);
napi_get_uv_event_loop(callback.second.env_, &loop);
uv_queue_work_with_qos(
loop, work, [](uv_work_t *work) {},
[](uv_work_t *work, int status) {

View File

@ -40,7 +40,6 @@ public:
std::shared_ptr<JSCallbackObject> cbCopy;
explicit UvEntry(const std::shared_ptr<JSCallbackObject> &cb) : cbCopy(cb) {}
};
napi_env env_ = nullptr;
ConcurrentMap<uint32_t, ConcurrentMap<std::string, std::shared_ptr<JSCallbackObject>>> callbacks_;
static std::mutex listenerMutex_;
static std::shared_ptr<PanelListenerImpl> instance_;