Fix some problems with our not so smart pointers.

This commit is contained in:
Pavel Krajcevski 2012-10-03 18:56:18 -04:00
parent 04cbf615f5
commit 6c723ca289

View file

@ -21,14 +21,29 @@ TCThreadBase::TCThreadBase(const TCThreadBase &other)
TCThreadBase &TCThreadBase::operator=(const TCThreadBase &other) {
assert(m_Impl->GetReferenceCount() > 0);
// We are no longer referencing this implementation...
m_Impl->DecreaseReferenceCount();
// If we're the last ones to reference it, then it should be destroyed.
if(m_Impl->GetReferenceCount() <= 0) {
delete m_Impl;
m_Impl = 0;
}
// Our implementation is now the same as the other.
m_Impl = other.m_Impl;
m_Impl->IncreaseReferenceCount();
}
TCThreadBase::~TCThreadBase() {
if(m_Impl->GetReferenceCount() <= 1) {
assert(m_Impl->GetReferenceCount() >= 0);
// We are no longer referencing this implementation...
m_Impl->DecreaseReferenceCount();
// If we're the last ones to reference it, then it should be destroyed.
if(m_Impl->GetReferenceCount() <= 0) {
assert(m_Impl->GetReferenceCount() == 0);
delete m_Impl;
}
}