diff --git a/base/src/refbase.cpp b/base/src/refbase.cpp index 04bc98eed3db9c62ccd2217571d536162d302c51..fd314d1e04b35740179288cbfc9d2c6ce6838868 100755 --- a/base/src/refbase.cpp +++ b/base/src/refbase.cpp @@ -164,7 +164,7 @@ int RefCounter::DecWeakRefCount(const void*) } } else { // free RefCounter - delete (this); + DecRefCount(); } } @@ -313,12 +313,10 @@ RefBase::~RefBase() { if (refs_ != nullptr) { refs_->RemoveCallback(); - if (refs_->IsLifeTimeExtended() && refs_->GetWeakRefCount() == 0) { + if ((refs_->IsLifeTimeExtended() && refs_->GetWeakRefCount() == 0) + || refs_->GetStrongRefCount() == INITIAL_PRIMARY_VALUE) { refs_->DecRefCount(); } - if (refs_->GetStrongRefCount() == INITIAL_PRIMARY_VALUE) { - delete refs_; - } refs_ = nullptr; } }