From 7bd3b9c302b5e4f252736de06ec9233732164140 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 18 Apr 2012 23:02:45 +0100 Subject: [PATCH] Retrace IUnknown::AddRef/Release correctly. --- retrace/retrace.py | 8 ++++++++ specs/winapi.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) 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", ()), ) -- 2.43.0