summaryrefslogtreecommitdiffstats
path: root/src/activeqt
diff options
context:
space:
mode:
authorJian Liang <jianliang79@gmail.com>2012-02-29 01:23:47 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-02-29 08:20:03 (GMT)
commit78faf96e5fd4bf6c1f37aa7f89229fa9bf3dd70d (patch)
tree9c2b2e57a77d53c4dbafbfacb5da2d6c0469619a /src/activeqt
parent0ba850c7a2dbccb8dd6aa1664679bda6cce95065 (diff)
downloadQt-78faf96e5fd4bf6c1f37aa7f89229fa9bf3dd70d.zip
Qt-78faf96e5fd4bf6c1f37aa7f89229fa9bf3dd70d.tar.gz
Qt-78faf96e5fd4bf6c1f37aa7f89229fa9bf3dd70d.tar.bz2
Make reference counting for QAxClientSite multi-processor safe
It is not safe to use ++long/--long to implement reference counting for COM object in multi-processor environment. We use InterlockedIncrement() and InterlockedDecrement() to implement reference counting. Change-Id: Ibfc5f3456cbaefb9267feb378483c5c60c305f00 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
Diffstat (limited to 'src/activeqt')
-rw-r--r--src/activeqt/container/qaxwidget.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp
index 92a1e11..a11ac7a 100644
--- a/src/activeqt/container/qaxwidget.cpp
+++ b/src/activeqt/container/qaxwidget.cpp
@@ -408,7 +408,7 @@ private:
CONTROLINFO control_info;
QSize sizehint;
- unsigned long ref;
+ LONG ref;
QAxWidget *widget;
QAxHostWidget *host;
#if !defined(Q_WS_WINCE)
@@ -774,16 +774,16 @@ void QAxClientSite::deactivate()
//**** IUnknown
unsigned long WINAPI QAxClientSite::AddRef()
{
- return ++ref;
+ return InterlockedIncrement(&ref);
}
unsigned long WINAPI QAxClientSite::Release()
{
- if (!--ref) {
+ LONG refCount = InterlockedDecrement(&ref);
+ if (!refCount)
delete this;
- return 0;
- }
- return ref;
+
+ return refCount;
}
HRESULT WINAPI QAxClientSite::QueryInterface(REFIID iid, void **iface)