mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2025-01-23 19:11:05 +00:00
Fix some problems with our not so smart pointers.
This commit is contained in:
parent
04cbf615f5
commit
6c723ca289
|
@ -21,14 +21,29 @@ TCThreadBase::TCThreadBase(const TCThreadBase &other)
|
||||||
|
|
||||||
TCThreadBase &TCThreadBase::operator=(const TCThreadBase &other) {
|
TCThreadBase &TCThreadBase::operator=(const TCThreadBase &other) {
|
||||||
assert(m_Impl->GetReferenceCount() > 0);
|
assert(m_Impl->GetReferenceCount() > 0);
|
||||||
|
|
||||||
|
// We are no longer referencing this implementation...
|
||||||
m_Impl->DecreaseReferenceCount();
|
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 = other.m_Impl;
|
||||||
m_Impl->IncreaseReferenceCount();
|
m_Impl->IncreaseReferenceCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
TCThreadBase::~TCThreadBase() {
|
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;
|
delete m_Impl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue