mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
IssueNo: #I60I21
Description: 跨线程析构NativeReference导致崩溃 Sig: SIG_ApplicationFramework Feature or Bugfix: Bugfix Binary Source: No Signed-off-by: 杨亮 <yangliang36@huawei.com> Change-Id: Id8cc9ebb2a25384952c4f7495fe99ba774b94f1d
This commit is contained in:
@@ -878,7 +878,44 @@ NativeValue* CreateJsServiceExtensionContext(NativeEngine& engine, std::shared_p
|
||||
|
||||
JSServiceExtensionConnection::JSServiceExtensionConnection(NativeEngine& engine) : engine_(engine) {}
|
||||
|
||||
JSServiceExtensionConnection::~JSServiceExtensionConnection() = default;
|
||||
JSServiceExtensionConnection::~JSServiceExtensionConnection()
|
||||
{
|
||||
if (jsConnectionObject_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
uv_loop_t *loop = engine_.GetUVLoop();
|
||||
if (loop == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
uv_work_t *work = new (std::nothrow) uv_work_t;
|
||||
if (work == nullptr) {
|
||||
return;
|
||||
}
|
||||
work->data = reinterpret_cast<void *>(jsConnectionObject_.release());
|
||||
int ret = uv_queue_work(loop, work, [](uv_work_t *work) {},
|
||||
[](uv_work_t *work, int status) {
|
||||
if (work == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (work->data == nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
return;
|
||||
}
|
||||
delete reinterpret_cast<NativeReference *>(work->data);
|
||||
work->data = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
});
|
||||
if (ret != 0) {
|
||||
delete reinterpret_cast<NativeReference *>(work->data);
|
||||
work->data = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void JSServiceExtensionConnection::SetConnectionId(int64_t id)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user