]> git.cworth.org Git - apitrace/commitdiff
Retrace IUnknown::AddRef/Release correctly.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Wed, 18 Apr 2012 22:02:45 +0000 (23:02 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Wed, 18 Apr 2012 22:02:45 +0000 (23:02 +0100)
retrace/retrace.py
specs/winapi.py

index 8198b0a31e19054b0c0e893d49b088e3cac8f809..2e0350107a64f7e17ced6f9145acc462053816e2 100644 (file)
@@ -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)
index 0941118f08310ddbad3e3e7ea1e889290c47a602..1638f6d8780b79fa68bc9d0e59e75dced42c0b92 100644 (file)
@@ -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", ()),
 )