|
|
|
@ -20,7 +20,7 @@
|
|
|
|
|
#ifndef _smart_pointer_hpp
|
|
|
|
|
#define _smart_pointer_hpp
|
|
|
|
|
|
|
|
|
|
#if defined TQT_THREAD_SUPPORT
|
|
|
|
|
#if defined QT_THREAD_SUPPORT
|
|
|
|
|
#include "tqmutex.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -41,27 +41,27 @@ class ref_count {
|
|
|
|
|
protected:
|
|
|
|
|
//! reference count member
|
|
|
|
|
long m_RefCount;
|
|
|
|
|
#ifdef TQT_THREAD_SUPPORT
|
|
|
|
|
#ifdef QT_THREAD_SUPPORT
|
|
|
|
|
TQMutex m_RefcountMutex;
|
|
|
|
|
#endif
|
|
|
|
|
public:
|
|
|
|
|
//! first reference must be added after "new" via Pointer()
|
|
|
|
|
ref_count() : m_RefCount(0)
|
|
|
|
|
#ifdef TQT_THREAD_SUPPORT
|
|
|
|
|
#ifdef QT_THREAD_SUPPORT
|
|
|
|
|
,m_RefcountMutex()
|
|
|
|
|
#endif
|
|
|
|
|
{}
|
|
|
|
|
virtual ~ref_count() {}
|
|
|
|
|
//! add a reference
|
|
|
|
|
void Incr() {
|
|
|
|
|
#ifdef TQT_THREAD_SUPPORT
|
|
|
|
|
#ifdef QT_THREAD_SUPPORT
|
|
|
|
|
TQMutexLocker a(&m_RefcountMutex);
|
|
|
|
|
#endif
|
|
|
|
|
++m_RefCount;
|
|
|
|
|
}
|
|
|
|
|
//! delete a reference
|
|
|
|
|
bool Decr() {
|
|
|
|
|
#ifdef TQT_THREAD_SUPPORT
|
|
|
|
|
#ifdef QT_THREAD_SUPPORT
|
|
|
|
|
TQMutexLocker a(&m_RefcountMutex);
|
|
|
|
|
#endif
|
|
|
|
|
--m_RefCount;
|
|
|
|
|