!9386 修复子窗过早析构造成crash

Merge pull request !9386 from tanchenghao/OpenHarmony-5.0-Release
This commit is contained in:
openharmony_ci 2024-09-29 10:52:50 +00:00 committed by Gitee
commit 2b9e48b340
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -569,10 +569,11 @@ void WindowSessionImpl::DestroySubWindow()
if (subIter != subWindowSessionMap_.end()) {
auto& subWindows = subIter->second;
for (auto iter = subWindows.begin(); iter != subWindows.end(); iter++) {
if ((*iter) == nullptr) {
auto subWindow = *iter;
if (subWindow == nullptr) {
continue;
}
if ((*iter)->GetPersistentId() == persistentId) {
if (subWindow->GetPersistentId() == persistentId) {
TLOGD(WmsLogTag::WMS_SUB, "Destroy sub window, persistentId: %{public}d", persistentId);
subWindows.erase(iter);
break;
@ -586,17 +587,18 @@ void WindowSessionImpl::DestroySubWindow()
if (mainIter != subWindowSessionMap_.end()) {
auto& subWindows = mainIter->second;
for (auto iter = subWindows.begin(); iter != subWindows.end(); iter = subWindows.begin()) {
if ((*iter) == nullptr) {
auto subWindow = *iter;
if (subWindow == nullptr) {
TLOGW(WmsLogTag::WMS_SUB, "Destroy sub window which is nullptr");
subWindows.erase(iter);
continue;
}
bool isExtDestroyed = (*iter)->property_ != nullptr && (*iter)->property_->GetExtensionFlag();
bool isExtDestroyed = subWindow->property_->GetExtensionFlag();
TLOGD(WmsLogTag::WMS_SUB, "Destroy sub window, persistentId: %{public}d, isExtDestroyed: %{public}d",
(*iter)->GetPersistentId(), isExtDestroyed);
auto ret = (*iter)->Destroy(isExtDestroyed);
subWindow->GetPersistentId(), isExtDestroyed);
auto ret = subWindow->Destroy(isExtDestroyed);
if (ret != WMError::WM_OK) {
TLOGE(WmsLogTag::WMS_SUB, "Destroy failed. persistentId: %{public}d", (*iter)->GetPersistentId());
TLOGE(WmsLogTag::WMS_SUB, "Destroy failed. persistentId: %{public}d", subWindow->GetPersistentId());
subWindows.erase(iter);
}
}