make uiContent_ available after Initialize/Restore

Signed-off-by: zcdqs <junfeng.lijunfeng@huawei.com>
Change-Id: Idfe1138cdabc19c2bf1b9efb722bb41f72030d09
This commit is contained in:
zcdqs
2022-04-19 18:44:25 +08:00
parent e4b2ddf205
commit f7f7322d25
+8 -5
View File
@@ -392,20 +392,23 @@ WMError WindowImpl::SetUIContent(const std::string& contentInfo,
NativeEngine* engine, NativeValue* storage, bool isdistributed, AppExecFwk::Ability* ability)
{
WLOGFI("SetUIContent contentInfo: %{public}s", contentInfo.c_str());
std::unique_ptr<Ace::UIContent> uiContent;
if (ability != nullptr) {
uiContent_ = Ace::UIContent::Create(ability);
uiContent = Ace::UIContent::Create(ability);
} else {
uiContent_ = Ace::UIContent::Create(context_.get(), engine);
uiContent = Ace::UIContent::Create(context_.get(), engine);
}
if (uiContent_ == nullptr) {
if (uiContent == nullptr) {
WLOGFE("fail to SetUIContent id: %{public}u", property_->GetWindowId());
return WMError::WM_ERROR_NULLPTR;
}
if (isdistributed) {
uiContent_->Restore(this, contentInfo, storage);
uiContent->Restore(this, contentInfo, storage);
} else {
uiContent_->Initialize(this, contentInfo, storage);
uiContent->Initialize(this, contentInfo, storage);
}
// make uiContent_ available after Initialize/Restore
uiContent_ = std::move(uiContent);
if (state_ == WindowState::STATE_SHOWN) {
Ace::ViewportConfig config;
Rect rect = GetRect();