diff options
Diffstat (limited to 'src/activeqt')
-rw-r--r-- | src/activeqt/container/qaxbase.cpp | 27 | ||||
-rw-r--r-- | src/activeqt/container/qaxscript.cpp | 12 |
2 files changed, 21 insertions, 18 deletions
diff --git a/src/activeqt/container/qaxbase.cpp b/src/activeqt/container/qaxbase.cpp index d83c12b..7f9c3c4 100644 --- a/src/activeqt/container/qaxbase.cpp +++ b/src/activeqt/container/qaxbase.cpp @@ -290,15 +290,15 @@ public: // IUnknown unsigned long __stdcall AddRef() { - return ref++; + return InterlockedIncrement(&ref); } unsigned long __stdcall Release() { - if (!--ref) { + LONG refCount = InterlockedDecrement(&ref); + if (!refCount) delete this; - return 0; - } - return ref; + + return refCount; } HRESULT __stdcall QueryInterface(REFIID riid, void **ppvObject) { @@ -538,7 +538,7 @@ public: QMap<DISPID, QByteArray> props; QAxBase *combase; - long ref; + LONG ref; }; /* @@ -4216,14 +4216,17 @@ public: AddRef(); return S_OK; } - unsigned long __stdcall AddRef() { return ++ref; } + unsigned long __stdcall AddRef() + { + return InterlockedIncrement(&ref); + } unsigned long __stdcall Release() { - if (!--ref) { + LONG refCount = InterlockedDecrement(&ref); + if (!refCount) delete this; - return 0; - } - return ref; + + return refCount; } HRESULT __stdcall Read(LPCOLESTR name, VARIANT *var, IErrorLog *) @@ -4250,7 +4253,7 @@ public: QAxBase::PropertyBag map; private: - unsigned long ref; + LONG ref; }; /*! diff --git a/src/activeqt/container/qaxscript.cpp b/src/activeqt/container/qaxscript.cpp index c5504ce..7166998 100644 --- a/src/activeqt/container/qaxscript.cpp +++ b/src/activeqt/container/qaxscript.cpp @@ -113,7 +113,7 @@ protected: private: QAxScript *script; - unsigned long ref; + LONG ref; }; /* @@ -129,7 +129,7 @@ QAxScriptSite::QAxScriptSite(QAxScript *s) */ ULONG WINAPI QAxScriptSite::AddRef() { - return ++ref; + return InterlockedIncrement(&ref); } /* @@ -137,11 +137,11 @@ ULONG WINAPI QAxScriptSite::AddRef() */ ULONG WINAPI QAxScriptSite::Release() { - if (!--ref) { + LONG refCount = InterlockedDecrement(&ref); + if (!refCount) delete this; - return 0; - } - return ref; + + return refCount; } /* |