notify ace before window destroy

Signed-off-by: qianlf <qianliangfang@huawei.com>
Change-Id: I8135b09145e4a830264f9ab151cb8ddcaf57ad38
This commit is contained in:
qianlf
2022-03-01 14:18:21 +08:00
parent 5fa98fe7f1
commit eba1024dee
3 changed files with 26 additions and 1 deletions
+5
View File
@@ -38,6 +38,10 @@ namespace OHOS::AbilityRuntime {
class Context;
}
namespace OHOS::Ace {
class UIContent;
}
namespace OHOS {
namespace Rosen {
class RSSurfaceNode;
@@ -125,6 +129,7 @@ public:
virtual WMError SetUIContent(const std::string& contentInfo, NativeEngine* engine,
NativeValue* storage, bool isdistributed = false) = 0;
virtual std::string GetContentInfo() = 0;
virtual Ace::UIContent* GetUIContent() const = 0;
virtual bool IsDecorEnable() const = 0;
virtual WMError Maximize() = 0;
+8
View File
@@ -127,6 +127,7 @@ public:
NativeValue* storage, bool isdistributed) override;
virtual std::string GetContentInfo() override;
virtual const std::shared_ptr<AbilityRuntime::Context> GetContext() const override;
virtual Ace::UIContent* GetUIContent() const override;
// colorspace, gamut
virtual bool IsSupportWideGamut() override;
@@ -158,6 +159,13 @@ private:
uiContent_->Destroy();
}
}
inline void NotifyBeforeSubWindowDestroy(sptr<Window>& window) const
{
auto uiContent = window->GetUIContent();
if (uiContent != nullptr) {
uiContent->Destroy();
}
}
void SetDefaultOption(); // for api7
bool IsWindowValid() const;
void OnVsync(int64_t timeStamp);
+13 -1
View File
@@ -365,6 +365,11 @@ WMError WindowImpl::SetUIContent(const std::string& contentInfo,
return WMError::WM_OK;
}
Ace::UIContent* WindowImpl::GetUIContent() const
{
return uiContent_.get();
}
std::string WindowImpl::GetContentInfo()
{
WLOGFI("GetContentInfo");
@@ -586,7 +591,13 @@ WMError WindowImpl::Destroy()
WLOGFI("[Client] Window %{public}d Destroy", property_->GetWindowId());
// FixMe: Remove "NotifyBeforeDestroy()" because of ACE bug, add when fixed
NotifyBeforeDestroy();
if (subWindowMap_.count(GetWindowId()) > 0) {
for (auto& subWindow : subWindowMap_.at(GetWindowId())) {
NotifyBeforeSubWindowDestroy(subWindow);
}
}
WMError ret = SingletonContainer::Get<WindowAdapter>().DestroyWindow(property_->GetWindowId());
if (ret != WMError::WM_OK) {
WLOGFE("destroy window failed with errCode:%{public}d", static_cast<int32_t>(ret));
@@ -607,6 +618,7 @@ WMError WindowImpl::Destroy()
// Destroy app floating window if exist
if (appFloatingWindowMap_.count(GetWindowId()) > 0) {
for (auto& floatingWindow : appFloatingWindowMap_.at(GetWindowId())) {
NotifyBeforeSubWindowDestroy(floatingWindow);
WMError fltRet = SingletonContainer::Get<WindowAdapter>().DestroyWindow(floatingWindow->GetWindowId());
if (fltRet == WMError::WM_OK) {
WLOGFI("Destroy App %{public}d FltWindow %{public}d", GetWindowId(), floatingWindow->GetWindowId());