Fixed variation of bug 2022935 by changing when functions check if strong-count is zero.
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@904 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
464f643e19
commit
c983337def
1 changed files with 33 additions and 28 deletions
|
@ -359,10 +359,12 @@ public:
|
|||
++m_weakCount;
|
||||
}
|
||||
|
||||
inline void DecStrongCount( void )
|
||||
inline bool DecStrongCount( void )
|
||||
{
|
||||
assert( 0 < m_strongCount );
|
||||
--m_strongCount;
|
||||
const bool isZero = ( 0 == m_strongCount );
|
||||
return isZero;
|
||||
}
|
||||
|
||||
inline void DecWeakCount( void )
|
||||
|
@ -483,11 +485,12 @@ public:
|
|||
m_Mutex.Unlock();
|
||||
}
|
||||
|
||||
inline void DecStrongCount( void )
|
||||
inline bool DecStrongCount( void )
|
||||
{
|
||||
m_Mutex.Lock();
|
||||
TwoRefCountInfo::DecStrongCount();
|
||||
const bool isZero = TwoRefCountInfo::DecStrongCount();
|
||||
m_Mutex.Unlock();
|
||||
return isZero;
|
||||
}
|
||||
|
||||
inline void DecWeakCount( void )
|
||||
|
@ -572,10 +575,6 @@ protected:
|
|||
return Decrement( strong );
|
||||
}
|
||||
|
||||
void Increment( bool strong );
|
||||
|
||||
bool Decrement( bool strong );
|
||||
|
||||
bool HasStrongPointer( void ) const
|
||||
{
|
||||
return m_counts->HasStrongPointer();
|
||||
|
@ -604,6 +603,10 @@ private:
|
|||
TwoRefCounts( void );
|
||||
TwoRefCounts & operator = ( const TwoRefCounts & );
|
||||
|
||||
void Increment( bool strong );
|
||||
|
||||
bool Decrement( bool strong );
|
||||
|
||||
/// Pointer to all shared data.
|
||||
Loki::Private::TwoRefCountInfo * m_counts;
|
||||
};
|
||||
|
@ -696,15 +699,17 @@ protected:
|
|||
|
||||
bool Decrement( bool strong )
|
||||
{
|
||||
bool noStrongPointers = false;
|
||||
if ( strong )
|
||||
{
|
||||
m_counts->DecStrongCount();
|
||||
noStrongPointers = m_counts->DecStrongCount();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_counts->DecWeakCount();
|
||||
noStrongPointers = !m_counts->HasStrongPointer();
|
||||
}
|
||||
return !m_counts->HasStrongPointer();
|
||||
return noStrongPointers;
|
||||
}
|
||||
|
||||
bool HasStrongPointer( void ) const
|
||||
|
@ -855,7 +860,7 @@ template
|
|||
template < class > class ConstnessPolicy = LOKI_DEFAULT_CONSTNESS
|
||||
>
|
||||
class StrongPtr
|
||||
: public OwnershipPolicy
|
||||
: protected OwnershipPolicy
|
||||
, public ConversionPolicy
|
||||
, public CheckingPolicy< T * >
|
||||
, public ResetPolicy< T >
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue