Update of /cvsroot/pywin32/pywin32/Pythonwin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11002
Modified Files:
win32cmd.cpp win32uimodule.cpp win32virt.cpp win32win.cpp
Log Message:
Fix bugs [1512715 ] CVirtualHelper::call / do_call double DODECREF Bug ?
and [1489690 ] Memory Leak: PyCWnd objects are never freed.
Thanks to kxroberto for help tracking these down.
Index: win32virt.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32virt.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** win32virt.cpp 7 Oct 2004 08:45:24 -0000 1.2
--- win32virt.cpp 11 Jul 2006 05:18:30 -0000 1.3
***************
*** 54,58 ****
py_ob = py_bob;
Py_INCREF(py_ob);
- // Py_XINCREF(handler);
}
CVirtualHelper::~CVirtualHelper()
--- 54,57 ----
***************
*** 387,391 ****
PyObject *arglst = Py_BuildValue("((iiiii(ii)))",msg->hwnd,msg->message,msg->wParam,msg->lParam,msg->time,msg->pt.x,msg->pt.y);
BOOL ret = do_call(arglst);
- DODECREF(arglst); // my reference.
return ret;
}
--- 386,389 ----
***************
*** 396,400 ****
PyObject *arglst = Py_BuildValue("iill",nID, nCode, (long)pExtra, (long)pHandlerInfo);
BOOL ret = do_call(arglst);
- DODECREF(arglst); // my reference.
return ret;
}
--- 394,397 ----
Index: win32uimodule.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uimodule.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** win32uimodule.cpp 21 Jun 2006 12:23:22 -0000 1.31
--- win32uimodule.cpp 11 Jul 2006 05:18:30 -0000 1.32
***************
*** 774,779 ****
result = gui_call_object( pCallbackCaller, newarglst );
DODECREF(newarglst);
! } else
result = gui_call_object( themeth, thearglst );
DODECREF(thearglst);
if (result==NULL) {
--- 774,785 ----
result = gui_call_object( pCallbackCaller, newarglst );
DODECREF(newarglst);
! } else {
! // Only ref to 'themeth' may be map - and if the message hook
! // updates the map (ie, removes the function), things get
! // a little pear-shaped - as witnessed in bug 1489690.
! Py_XINCREF(themeth);
result = gui_call_object( themeth, thearglst );
+ Py_XDECREF(themeth);
+ }
DODECREF(thearglst);
if (result==NULL) {
Index: win32win.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32win.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** win32win.cpp 18 Apr 2005 13:36:46 -0000 1.9
--- win32win.cpp 11 Jul 2006 05:18:30 -0000 1.10
***************
*** 264,268 ****
CHECK_NO_ARGS(args);
CWnd *pWnd = new CPythonWndFramework< CWnd >();
! return ui_assoc_object::make( PyCWnd::type, pWnd );
}
// @pymethod |PyCWnd|CreateWindow|Creates the actual window
--- 264,273 ----
CHECK_NO_ARGS(args);
CWnd *pWnd = new CPythonWndFramework< CWnd >();
! PyCWnd *pRet = (PyCWnd *)ui_assoc_object::make( PyCWnd::type, pWnd );
! // We explicitly created this CWnd, so we must explicitly nuke it!
! if (pRet) {
! pRet->bManualDelete = TRUE;
! }
! return pRet;
}
// @pymethod |PyCWnd|CreateWindow|Creates the actual window
Index: win32cmd.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32cmd.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** win32cmd.cpp 1 Sep 1999 23:33:00 -0000 1.1
--- win32cmd.cpp 11 Jul 2006 05:18:30 -0000 1.2
***************
*** 220,224 ****
if (pList->Lookup(message, oldMethod)) {
pList->RemoveKey(message);
! // DODECREF((PyObject *)oldMethod);
DODECREF(hookedObject);
}
--- 220,224 ----
if (pList->Lookup(message, oldMethod)) {
pList->RemoveKey(message);
! // oldMethod is returned - don't drop its reference.
DODECREF(hookedObject);
}
|