diff --git a/base/src/refbase.cpp b/base/src/refbase.cpp index a39676c1989d7da4622cc56e95164713643584ab..562977cfca4e10469e6e45001a4dcb14eacc799d 100644 --- a/base/src/refbase.cpp +++ b/base/src/refbase.cpp @@ -457,6 +457,9 @@ RefBase &RefBase::operator=(const RefBase &) { if (refs_ != nullptr) { refs_->RemoveCallback(); +#ifdef OHOS_PLATFORM + refs_->RemoveCanPromote(); +#endif refs_->DecRefCount(); } @@ -486,6 +489,9 @@ RefBase &RefBase::operator=(RefBase &&other) noexcept if (refs_ != nullptr) { refs_->RemoveCallback(); +#ifdef OHOS_PLATFORM + refs_->RemoveCanPromote(); +#endif refs_->DecRefCount(); } @@ -498,6 +504,9 @@ RefBase::~RefBase() { if (refs_ != nullptr) { refs_->RemoveCallback(); +#ifdef OHOS_PLATFORM + refs_->RemoveCanPromote(); +#endif if ((refs_->IsLifeTimeExtended() && refs_->GetWeakRefCount() == 0) || refs_->GetStrongRefCount() == INITIAL_PRIMARY_VALUE) { refs_->DecRefCount();