From b9c44f9d1281496e73adee0672ccefcd92e41ba5 Mon Sep 17 00:00:00 2001 From: Caoruihong Date: Sat, 25 Nov 2023 00:59:42 +0800 Subject: [PATCH] refactor: move constant container instance IDs definations to container.h Signed-off-by: Caoruihong --- frameworks/core/common/container.h | 2 ++ frameworks/core/common/container_scope.cpp | 1 + frameworks/core/common/container_scope.h | 6 +----- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/frameworks/core/common/container.h b/frameworks/core/common/container.h index 80121ceeb76..1ec5bb9f35b 100755 --- a/frameworks/core/common/container.h +++ b/frameworks/core/common/container.h @@ -63,6 +63,8 @@ enum ContainerType { PLUGIN_SUBCONTAINER = 20, }; +constexpr int32_t INSTANCE_ID_UNDEFINED = -1; +constexpr int32_t INSTANCE_ID_PLATFORM = -2; constexpr int32_t CONTAINER_ID_DIVIDE_SIZE = 100000; constexpr int32_t MIN_PLUGIN_SUBCONTAINER_ID = PLUGIN_SUBCONTAINER * CONTAINER_ID_DIVIDE_SIZE; constexpr int32_t MIN_SUBCONTAINER_ID = COMPONENT_SUBWINDOW_CONTAINER * CONTAINER_ID_DIVIDE_SIZE; diff --git a/frameworks/core/common/container_scope.cpp b/frameworks/core/common/container_scope.cpp index 15daa87a94f..61415453826 100644 --- a/frameworks/core/common/container_scope.cpp +++ b/frameworks/core/common/container_scope.cpp @@ -14,6 +14,7 @@ */ #include "core/common/container_scope.h" +#include "core/common/container.h" #include "base/utils/utils.h" namespace OHOS::Ace { diff --git a/frameworks/core/common/container_scope.h b/frameworks/core/common/container_scope.h index 0bf416e920f..9d001100841 100644 --- a/frameworks/core/common/container_scope.h +++ b/frameworks/core/common/container_scope.h @@ -23,14 +23,10 @@ namespace OHOS::Ace { -constexpr int32_t INSTANCE_ID_UNDEFINED = -1; -constexpr int32_t INSTANCE_ID_PLATFORM = -2; - class ACE_EXPORT ContainerScope { public: explicit ContainerScope(int32_t id) { - restoreId_ = CurrentId(); UpdateCurrent(id); } @@ -44,7 +40,7 @@ public: static void UpdateCurrent(int32_t id); private: - int32_t restoreId_ = INSTANCE_ID_UNDEFINED; + int32_t restoreId_ = CurrentId(); ACE_DISALLOW_COPY_AND_MOVE(ContainerScope); }; -- Gitee