From: José Fonseca <jose.r.fonseca@gmail.com>
Date: Wed, 18 Apr 2012 22:02:45 +0000 (+0100)
Subject: Retrace IUnknown::AddRef/Release correctly.
X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=7bd3b9c302b5e4f252736de06ec9233732164140;p=apitrace

Retrace IUnknown::AddRef/Release correctly.
---

diff --git a/retrace/retrace.py b/retrace/retrace.py
index 8198b0a..2e03501 100644
--- a/retrace/retrace.py
+++ b/retrace/retrace.py
@@ -422,6 +422,14 @@ class Retracer:
             print '    %s(%s);' % (function.name, arg_names)
 
     def invokeInterfaceMethod(self, interface, method):
+        # On release our reference when we reach Release() == 0 call in the
+        # trace.
+        if method.name == 'Release':
+            print '    if (call.ret->toUInt()) {'
+            print '        return;'
+            print '    }'
+            print '    _obj_map.erase(call.arg(0).toUIntPtr());'
+
         arg_names = ", ".join(method.argNames())
         if method.type is not stdapi.Void:
             print '    %s __result;' % (method.type)
diff --git a/specs/winapi.py b/specs/winapi.py
index 0941118..1638f6d 100644
--- a/specs/winapi.py
+++ b/specs/winapi.py
@@ -204,7 +204,7 @@ IUnknown = Interface("IUnknown")
 
 IUnknown.methods = (
 	Method(HRESULT, "QueryInterface", ((REFIID, "riid"), Out(Pointer(ObjPointer(Void)), "ppvObj"))),
-	Method(ULONG, "AddRef", ()),
+	Method(ULONG, "AddRef", (), sideeffects=False),
 	Method(ULONG, "Release", ()),
 )