diff --git a/adapter/preview/entrance/ace_ability.cpp b/adapter/preview/entrance/ace_ability.cpp index cabb57ca..c9fa03f3 100644 --- a/adapter/preview/entrance/ace_ability.cpp +++ b/adapter/preview/entrance/ace_ability.cpp @@ -491,7 +491,8 @@ bool AceAbility::OperateComponent(const std::string& attrsJson) auto container = AceContainer::GetContainerInstance(ACE_INSTANCE_ID); auto taskExecutor = container->GetTaskExecutor(); taskExecutor->PostTask( - [attrsJson] { + [attrsJson, instanceId = ACE_INSTANCE_ID] { + ContainerScope scope(instanceId); bool result = OHOS::Ace::Framework::InspectorClient::GetInstance().OperateComponent(attrsJson); if (!result) { OHOS::Ace::Framework::InspectorClient::GetInstance().CallFastPreviewErrorCallback(attrsJson); diff --git a/frameworks/core/common/container_scope.cpp b/frameworks/core/common/container_scope.cpp index b02ff28a..04e3692a 100644 --- a/frameworks/core/common/container_scope.cpp +++ b/frameworks/core/common/container_scope.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,11 +17,7 @@ namespace OHOS::Ace { -#ifndef WINDOWS_PLATFORM thread_local int32_t ContainerScope::currentId_ = -1; -#else -int32_t ContainerScope::currentId_ = -1; -#endif std::function ContainerScope::updateScopeNotify_; int32_t ContainerScope::CurrentId() diff --git a/frameworks/core/common/container_scope.h b/frameworks/core/common/container_scope.h index 319fe2fc..880cdd50 100644 --- a/frameworks/core/common/container_scope.h +++ b/frameworks/core/common/container_scope.h @@ -44,11 +44,7 @@ public: static void SetScopeNotify(std::function&& notify); private: -#ifndef WINDOWS_PLATFORM static thread_local int32_t currentId_; -#else - static int32_t currentId_; -#endif int32_t restoreId_ = -1; static std::function updateScopeNotify_;