Update of /cvsroot/pywin32/pywin32/Pythonwin
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27228/Pythonwin
Modified Files:
ddeconv.cpp ddeitem.cpp ddeserver.cpp ddetopic.cpp dllmain.cpp
pythonpsheet.cpp win32RichEdit.cpp
win32RichEditDocTemplate.cpp win32app.cpp win32assoc.cpp
win32assoc.h win32bitmap.cpp win32brush.cpp win32cmd.cpp
win32cmd.h win32cmdui.cpp win32cmdui.h win32control.cpp
win32control.h win32ctledit.cpp win32ctrlList.cpp
win32ctrlRichEdit.cpp win32ctrlTree.cpp win32dc.cpp win32dc.h
win32dlg.cpp win32dlg.h win32dlgbar.cpp win32dll.cpp
win32dll.h win32doc.cpp win32font.cpp win32gdi.cpp win32gdi.h
win32hl.h win32menu.cpp win32notify.cpp win32oleDlgInsert.cpp
win32oleDlgs.cpp win32pen.cpp win32prinfo.cpp win32prinfo.h
win32prop.cpp win32prop.h win32rgn.cpp win32splitter.cpp
win32template.cpp win32thread.cpp win32toolbar.cpp
win32toolbar.h win32tooltip.cpp win32ui.h win32uimodule.cpp
win32uioleClientItem.cpp win32uioledoc.cpp win32util.cpp
win32view.cpp win32virt.cpp win32win.cpp win32win.h
Log Message:
Merge from py3k branch:
* Roger's work to move to getattr and using builtin Python inheritance.
* Move to using weak-references to store associations between MFC objects
and Python objects.
* Lots of memory leaks fixed
Index: win32ctledit.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32ctledit.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** win32ctledit.cpp 13 Nov 2008 04:04:50 -0000 1.2
--- win32ctledit.cpp 8 Jan 2009 22:11:52 -0000 1.3
***************
*** 424,427 ****
--- 424,428 ----
RUNTIME_CLASS(CEdit),
sizeof(PyCEdit),
+ PYOBJ_OFFSET(PyCEdit),
PyCEdit_methods,
GET_PY_CTOR(PyCEdit));
Index: win32app.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32app.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** win32app.cpp 13 Nov 2008 04:04:50 -0000 1.7
--- win32app.cpp 8 Jan 2009 22:11:52 -0000 1.8
***************
*** 416,419 ****
--- 416,420 ----
RUNTIME_CLASS(CWinApp),
sizeof(PyCWinApp),
+ PYOBJ_OFFSET(PyCWinApp),
PyCWinApp_methods,
GET_PY_CTOR(PyCWinApp) );
Index: win32win.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32win.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** win32win.cpp 5 Jan 2009 10:47:28 -0000 1.23
--- win32win.cpp 8 Jan 2009 22:11:52 -0000 1.24
***************
*** 70,75 ****
BOOL Python_check_message(const MSG *msg) // TRUE if fully processed.
{
!
! ui_assoc_object *pObj;
PyObject *method;
CWnd *pWnd = bInFatalShutdown ? NULL : CWnd::FromHandlePermanent(msg->hwnd);
--- 70,75 ----
BOOL Python_check_message(const MSG *msg) // TRUE if fully processed.
{
! BOOL ret;
! ui_assoc_object *pObj = NULL;
PyObject *method;
CWnd *pWnd = bInFatalShutdown ? NULL : CWnd::FromHandlePermanent(msg->hwnd);
***************
*** 77,81 ****
CEnterLeavePython _celp;
if (pWnd &&
! (pObj=ui_assoc_object::GetPyObject(pWnd)) &&
pObj->is_uiobject( &PyCWnd::type ) &&
((PyCWnd *)pObj)->pMessageHookList &&
--- 77,81 ----
CEnterLeavePython _celp;
if (pWnd &&
! (pObj=ui_assoc_object::GetAssocObject(pWnd)) &&
pObj->is_uiobject( &PyCWnd::type ) &&
((PyCWnd *)pObj)->pMessageHookList &&
***************
*** 87,93 ****
// Our Python convention is TRUE means "pass it on"
// CEnterLeavePython _celp;
! return Python_callback(method, msg)==0;
! }
! return FALSE; // dont want it.
}
--- 87,95 ----
// Our Python convention is TRUE means "pass it on"
// CEnterLeavePython _celp;
! ret = Python_callback(method, msg)==0;
! } else
! ret = FALSE; // dont want it.
! Py_XDECREF(pObj);
! return ret;
}
***************
*** 95,104 ****
{
CEnterLeavePython _celp;
! ui_assoc_object *pObj;
BOOL bPassOn = TRUE;
CWnd *pWnd = msg->hwnd ? CWnd::FromHandlePermanent(msg->hwnd) : NULL;
! if (pWnd && (pObj=ui_assoc_object::GetPyObject(pWnd)) &&
pObj->is_uiobject( &PyCWnd::type ))
bPassOn = ((PyCWnd*)pObj)->check_key_stroke(msg->wParam);
return !bPassOn;
}
--- 97,107 ----
{
CEnterLeavePython _celp;
! ui_assoc_object *pObj = NULL;
BOOL bPassOn = TRUE;
CWnd *pWnd = msg->hwnd ? CWnd::FromHandlePermanent(msg->hwnd) : NULL;
! if (pWnd && (pObj=ui_assoc_object::GetAssocObject(pWnd)) &&
pObj->is_uiobject( &PyCWnd::type ))
bPassOn = ((PyCWnd*)pObj)->check_key_stroke(msg->wParam);
+ Py_XDECREF(pObj);
return !bPassOn;
}
***************
*** 598,630 ****
PyCWnd::~PyCWnd()
{
- DoKillAssoc(TRUE);
- }
-
- BOOL PyCWnd::check_key_stroke(WPARAM ch)
- {
- PyObject *pythonObject;
- BOOL bCallBase = TRUE;
- if (obKeyStrokeHandler!= NULL)
- bCallBase = Python_callback(obKeyStrokeHandler, ch);
-
- if (bCallBase && pKeyHookList && pKeyHookList->Lookup((WORD)ch, (void *&)pythonObject))
- bCallBase = Python_callback(pythonObject,ch);
- return bCallBase;
- }
-
- CWnd *PyCWnd::GetPythonGenericWnd(PyObject *self, ui_type_CObject *pType)
- {
- // Damn it - only pass PyCWnd::type so the RTTI check wont fail
- // for builtin controls.
- return (CWnd *)GetGoodCppObject( self, &type );
- }
-
- void PyCWnd::DoKillAssoc( BOOL bDestructing /*= FALSE*/ )
- {
free_hook_list(this,&pMessageHookList);
free_hook_list(this,&pKeyHookList);
Py_XDECREF(obKeyStrokeHandler);
obKeyStrokeHandler = NULL;
- PyCCmdTarget::DoKillAssoc(bDestructing);
if (bManualDelete || bDidSubclass) {
// Can't use GetWndPtr(this) as ob_type has been nuked.
--- 601,608 ----
***************
*** 632,644 ****
if (pWnd) {
if (bDidSubclass) {
- // pWnd->Detach();
pWnd->UnsubclassWindow();
bDidSubclass = FALSE;
}
- // DONT detach - bDidSubclass is only logic needed.
- // if (pWnd->GetSafeHwnd()) {
- // TRACE("Warning - DoKillAssoc detaching from existing window\n");
- // pWnd->Detach();
- // }
if (bManualDelete) {
// Release the lock while we destroy the object.
--- 610,616 ----
***************
*** 651,654 ****
--- 623,646 ----
}
}
+
+ BOOL PyCWnd::check_key_stroke(WPARAM ch)
+ {
+ PyObject *pythonObject;
+ BOOL bCallBase = TRUE;
+ if (obKeyStrokeHandler!= NULL)
+ bCallBase = Python_callback(obKeyStrokeHandler, ch);
+
+ if (bCallBase && pKeyHookList && pKeyHookList->Lookup((WORD)ch, (void *&)pythonObject))
+ bCallBase = Python_callback(pythonObject,ch);
+ return bCallBase;
+ }
+
+ CWnd *PyCWnd::GetPythonGenericWnd(PyObject *self, ui_type_CObject *pType)
+ {
+ // Damn it - only pass PyCWnd::type so the RTTI check wont fail
+ // for builtin controls.
+ return (CWnd *)GetGoodCppObject( self, &type );
+ }
+
/*static*/ PyCWnd *PyCWnd::make( ui_type_CObject &makeType, CWnd *pSearch, HWND wnd /*=NULL*/ )
{
***************
*** 2719,2724 ****
RETURN_ERR("BeginPaint failed");
PyObject *obDC = ui_assoc_object::make (ui_dc_object::type, pTemp)->GetGoodRet();
! PyObject *obRet = Py_BuildValue("O(ii(iiii)iiN)", obDC,
! ps.hdc,
ps.fErase,
ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom,
--- 2711,2716 ----
RETURN_ERR("BeginPaint failed");
PyObject *obDC = ui_assoc_object::make (ui_dc_object::type, pTemp)->GetGoodRet();
! PyObject *obRet = Py_BuildValue("O(Ni(iiii)iiN)", obDC,
! PyWinLong_FromHANDLE(ps.hdc),
ps.fErase,
ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom,
***************
*** 3195,3201 ****
PyObject* ui_window_set_icon(PyObject* self, PyObject *args)
{
! HICON hiconPrevIcon;
BOOL bBigIcon = TRUE;
! if (!PyArg_ParseTuple(args, "ii:SetIcon", &hiconPrevIcon, &bBigIcon))
return NULL;
CWnd *pWnd = GetWndPtr(self);
--- 3187,3196 ----
PyObject* ui_window_set_icon(PyObject* self, PyObject *args)
{
! PyObject *obiconprev;
BOOL bBigIcon = TRUE;
! if (!PyArg_ParseTuple(args, "Oi:SetIcon", &obiconprev, &bBigIcon))
! return NULL;
! HICON hiconprev;
! if (!PyWinObject_AsHANDLE(obiconprev, (HANDLE *)&hiconprev))
return NULL;
CWnd *pWnd = GetWndPtr(self);
***************
*** 3203,3207 ****
return NULL;
GUI_BGN_SAVE;
! HICON hiconRetVal = pWnd->SetIcon(hiconPrevIcon, bBigIcon);
GUI_END_SAVE;
return PyWinLong_FromHANDLE(hiconRetVal);
--- 3198,3202 ----
return NULL;
GUI_BGN_SAVE;
! HICON hiconRetVal = pWnd->SetIcon(hiconprev, bBigIcon);
GUI_END_SAVE;
return PyWinLong_FromHANDLE(hiconRetVal);
***************
*** 3347,3350 ****
--- 3342,3346 ----
RUNTIME_CLASS(CWnd),
sizeof(PyCWnd),
+ PYOBJ_OFFSET(PyCWnd),
PyCWnd_methods,
GET_PY_CTOR(PyCWnd) );
***************
*** 3952,3955 ****
--- 3948,3952 ----
RUNTIME_CLASS(CFrameWnd),
sizeof(PyCFrameWnd),
+ PYOBJ_OFFSET(PyCFrameWnd),
PyCFrameWnd_methods,
GET_PY_CTOR(PyCFrameWnd));
***************
*** 4124,4127 ****
--- 4121,4125 ----
RUNTIME_CLASS(CMDIFrameWnd),
sizeof(PyCMDIFrameWnd),
+ PYOBJ_OFFSET(PyCMDIFrameWnd),
PyCMDIFrameWnd_methods,
GET_PY_CTOR(PyCMDIFrameWnd));
***************
*** 4310,4313 ****
--- 4308,4312 ----
RUNTIME_CLASS(CMDIChildWnd),
sizeof(PyCMDIChildWnd),
+ PYOBJ_OFFSET(PyCMDIChildWnd),
PyCMDIChildWnd_methods,
GET_PY_CTOR(PyCMDIChildWnd));
Index: win32assoc.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32assoc.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** win32assoc.cpp 28 Dec 2008 10:10:02 -0000 1.11
--- win32assoc.cpp 8 Jan 2009 22:11:52 -0000 1.12
***************
*** 15,18 ****
--- 15,24 ----
#include "stdafx.h"
+ #ifdef DEBUG
+ #define ASSERT_GIL_HELD {PyGILState_STATE s=PyGILState_Ensure();ASSERT(s==PyGILState_LOCKED);PyGILState_Release(s);}
+ #else
+ #define ASSERT_GIL_HELD
+ #endif
+
CAssocManager ui_assoc_object::handleMgr;
***************
*** 20,24 ****
{
lastLookup = NULL;
! lastObject = NULL;
#ifdef _DEBUG
cacheLookups = cacheHits = 0;
--- 26,30 ----
{
lastLookup = NULL;
! lastObjectWeakRef = NULL;
#ifdef _DEBUG
cacheLookups = cacheHits = 0;
***************
*** 48,85 ****
ASSERT_VALID(&map);
TRACE("CAssocManager cleaning up %d objects\n", map.GetCount());
! m_critsec.Lock();
for(pos=map.GetStartPosition();pos;) {
map.GetNextAssoc(pos, (void *&)assoc, (void *&)ob);
! ob->cleanup();
! // not sure if I should do this!!
! //PyMem_DEL(ob);
}
- m_critsec.Unlock();
}
! void CAssocManager::Assoc(void *handle, ui_assoc_object *object, void *oldHandle)
{
! m_critsec.Lock();
! if (oldHandle) {
! // if window previously closed, this may fail when the Python object
! // destructs - but this is not a problem.
! map.RemoveKey(oldHandle);
! if (oldHandle==lastLookup)
! lastLookup = 0; // set cache invalid.
}
- if (handle)
- map.SetAt(handle, object);
- if (handle==lastLookup)
- lastObject = object;
- m_critsec.Unlock();
}
//
// CAssocManager::GetAssocObject
! //
! ui_assoc_object *CAssocManager::GetAssocObject(const void * handle)
{
if (handle==NULL) return NULL; // no possible association for NULL!
! ui_assoc_object *ret;
! m_critsec.Lock();
#ifdef _DEBUG
cacheLookups++;
--- 54,121 ----
ASSERT_VALID(&map);
TRACE("CAssocManager cleaning up %d objects\n", map.GetCount());
! CEnterLeavePython _celp;
for(pos=map.GetStartPosition();pos;) {
map.GetNextAssoc(pos, (void *&)assoc, (void *&)ob);
! RemoveAssoc(assoc);
}
}
!
! void CAssocManager::RemoveAssoc(void *handle)
{
! // nuke any existing items.
! PyObject *weakref;
! if (map.Lookup(handle, (void *&)weakref)) {
! PyObject *ob = PyWeakref_GetObject(weakref);
! map.RemoveKey(handle);
! if (ob != Py_None)
! // The object isn't necessarily dead (ie, its refcount may
! // not be about to hit zero), but its 'dead' from our POV, so
! // let it free any MFC etc resources the object owns.
! // XXX - this kinda sucks - just relying on the object
! // destructor *should* be OK...
! ((ui_assoc_object *)ob)->cleanup();
! Py_DECREF(weakref);
! }
! lastObjectWeakRef = 0;
! lastLookup = 0; // set cache invalid.
! }
!
! void CAssocManager::Assoc(void *handle, ui_assoc_object *object)
! {
! ASSERT_GIL_HELD; // we rely on the GIL to serialize access to our map...
! ASSERT(handle);
! #ifdef DEBUG
! // overwriting an existing entry probably means we are failing to
! // detect the death of the old object and its address has been reused.
! if (object) { // might just be nuking ours, so we expect to find outself!
! PyObject *existing_weakref;
! if (map.Lookup(handle, (void *&)existing_weakref)) {
! TRACE("CAssocManager::Assoc overwriting existing assoc\n");
! DebugBreak();
! }
! }
! #endif
! RemoveAssoc(handle);
! if (object) {
! PyObject *weakref = PyWeakref_NewRef(object, NULL);
! if (weakref)
! // reference owned by the map.
! map.SetAt(handle, weakref);
! else {
! TRACE("Failed to create weakref\n");
! gui_print_error();
! DebugBreak();
! }
}
}
//
// CAssocManager::GetAssocObject
! // Returns an object *with a new reference*. NULL is not an error return - it just means "no object"
! ui_assoc_object *CAssocManager::GetAssocObject(void * handle)
{
if (handle==NULL) return NULL; // no possible association for NULL!
! ASSERT_GIL_HELD; // we rely on the GIL to serialize access to our map...
! PyObject *weakref;
#ifdef _DEBUG
cacheLookups++;
***************
*** 87,91 ****
// implement a basic 1 item cache.
if (lastLookup==handle) {
! ret = lastObject;
#ifdef _DEBUG
++cacheHits;
--- 123,127 ----
// implement a basic 1 item cache.
if (lastLookup==handle) {
! weakref = lastObjectWeakRef;
#ifdef _DEBUG
++cacheHits;
***************
*** 93,102 ****
}
else {
! if (!map.Lookup((void *)handle, (void *&)ret))
! ret = NULL;
lastLookup = handle;
! lastObject = ret;
}
- m_critsec.Unlock();
return ret;
}
--- 129,157 ----
}
else {
! if (!map.Lookup((void *)handle, (void *&)weakref))
! weakref = NULL;
lastLookup = handle;
! lastObjectWeakRef = weakref;
! }
! if (weakref==NULL)
! return NULL;
! // convert the weakref object into a real object.
! PyObject *ob = PyWeakref_GetObject(weakref);
! if (ob == NULL) {
! // an error - but a NULL return from us just means "no assoc"
! // so print the error and ignore it, treating it as if the
! // weak-ref target has died.
! gui_print_error();
! ob = Py_None;
! }
! ui_assoc_object *ret;
! if (ob == Py_None) {
! // weak-ref target has died. Remove it from the map.
! Assoc(handle, NULL);
! ret = NULL;
! } else {
! ret = (ui_assoc_object *)ob;
! Py_INCREF(ret);
}
return ret;
}
***************
*** 191,194 ****
--- 246,250 ----
&ui_base_class::type,
sizeof(ui_assoc_object),
+ PYOBJ_OFFSET(ui_assoc_object),
PyAssocObject_methods,
NULL);
***************
*** 201,211 ****
ui_assoc_object::~ui_assoc_object()
{
- KillAssoc();
- }
-
- // handle is invalid - therefore release all refs I am holding for it.
- // ASSUMES WE HOLD THE PYTHON LOCK as for all Python object destruction.
- void ui_assoc_object::KillAssoc()
- {
#ifdef TRACE_ASSOC
CString rep = repr();
--- 257,260 ----
***************
*** 213,248 ****
TRACE("Destroying association with %p and %s",this,szRep);
#endif
! // note that _any_ of these may cause this to be deleted, as the reference
! // count may drop to zero. If any one dies, and later ones will fail. Therefore
! // I incref first, and decref at the end.
! // Note that this _always_ recurses when this happens as the destructor also
! // calls us to cleanup. Forcing an INCREF/DODECREF in that situation causes death
! // by recursion, as each dec back to zero causes a delete.
! BOOL bDestructing = ob_refcnt==0;
! if (!bDestructing)
! Py_INCREF(this);
! DoKillAssoc(bDestructing); // kill all map entries, etc.
! SetAssocInvalid(); // let child do whatever to detect
! if (!bDestructing)
! DODECREF(this);
! }
! // the virtual version...
! // ASSUMES WE HOLD THE PYTHON LOCK as for all Python object destruction.
! void ui_assoc_object::DoKillAssoc( BOOL bDestructing /*= FALSE*/ )
! {
! // In Python debug builds, this can get recursive -
! // Python temporarily increments the refcount of the dieing
! // object - this object death will attempt to use the dieing object.
! PyObject *vi = virtualInst;
! virtualInst = NULL;
! Py_XDECREF(vi);
// virtuals.DeleteAll();
! handleMgr.Assoc(0,this,assoc);
! }
!
! // return an object, given an association, if we have one.
! /* static */ ui_assoc_object *ui_assoc_object::GetPyObject(void *search)
! {
! return (ui_assoc_object *)handleMgr.GetAssocObject(search);
}
--- 262,271 ----
TRACE("Destroying association with %p and %s",this,szRep);
#endif
! Py_CLEAR(virtualInst);
// virtuals.DeleteAll();
! if (assoc) {
! handleMgr.Assoc(assoc, 0);
! SetAssocInvalid(); // let child do whatever to detect
! }
}
***************
*** 262,265 ****
--- 285,289 ----
{
ASSERT(search); // really only a C++ problem.
+ CEnterLeavePython _celp;
ui_assoc_object* ret=NULL;
if (!skipLookup)
***************
*** 272,276 ****
return NULL;
}
- DOINCREF( ret );
return ret;
}
--- 296,299 ----
***************
*** 283,288 ****
TRACE_ASSOC (" Associating 0x%x with 0x%x", search, ret);
#endif
! // if I have an existing handle, remove it.
! handleMgr.Assoc(search, ret,NULL);
ret->assoc = search;
}
--- 306,310 ----
TRACE_ASSOC (" Associating 0x%x with 0x%x", search, ret);
#endif
! handleMgr.Assoc(search, ret);
ret->assoc = search;
}
***************
*** 338,341 ****
--- 360,364 ----
RUNTIME_CLASS(CObject),
sizeof(ui_assoc_CObject),
+ PYOBJ_OFFSET(ui_assoc_CObject),
PyAssocCObject_methods,
NULL);
***************
*** 351,355 ****
bManualDelete = FALSE;
CObject *pO = (CObject *)GetGoodCppObject(&type); // get pointer before killing it.
! KillAssoc(); // stop recursion - disassociate now.
if (!pO)
PyErr_Clear();
--- 374,378 ----
bManualDelete = FALSE;
CObject *pO = (CObject *)GetGoodCppObject(&type); // get pointer before killing it.
! ASSERT(!PyErr_Occurred()); // PyErr_Clear() is bogus?????
if (!pO)
PyErr_Clear();
Index: win32ctrlRichEdit.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32ctrlRichEdit.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** win32ctrlRichEdit.cpp 13 Nov 2008 04:04:50 -0000 1.5
--- win32ctrlRichEdit.cpp 8 Jan 2009 22:11:52 -0000 1.6
***************
*** 866,884 ****
return NULL;
CHECK_NO_ARGS2(args,GetSelText);
! long start=0, end=0;
GUI_BGN_SAVE;
! pEdit->GetSel(start, end);
GUI_END_SAVE;
! PyObject *ret;
! if (end-start) {
! ret = PyString_FromStringAndSize(NULL, end-start);
! char *buf = PyString_AsString(ret);
! GUI_BGN_SAVE;
! pEdit->GetSelText(buf);
! GUI_END_SAVE;
! }
! else
! ret = PyString_FromStringAndSize("", 0);
! return ret;
}
--- 866,874 ----
return NULL;
CHECK_NO_ARGS2(args,GetSelText);
! CString str;
GUI_BGN_SAVE;
! str = pEdit->GetSelText();
GUI_END_SAVE;
! return PyWinObject_FromTCHAR(str);
}
***************
*** 924,927 ****
};
! PyCCtrlView_Type PyCRichEditCtrl::type("PyCRichEditCtrl",&ui_control_object::type, &PyCRichEditCtrl::type, RUNTIME_CLASS(CRichEditCtrl), sizeof(PyCRichEditCtrl), PyCRichEditCtrl_methods, GET_PY_CTOR(PyCRichEditCtrl));
--- 914,924 ----
};
! PyCCtrlView_Type PyCRichEditCtrl::type("PyCRichEditCtrl",
! &ui_control_object::type,
! &PyCRichEditCtrl::type,
! RUNTIME_CLASS(CRichEditCtrl),
! sizeof(PyCRichEditCtrl),
! PYOBJ_OFFSET(PyCRichEditCtrl),
! PyCRichEditCtrl_methods,
! GET_PY_CTOR(PyCRichEditCtrl));
Index: win32view.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32view.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** win32view.cpp 13 Nov 2008 04:04:50 -0000 1.5
--- win32view.cpp 8 Jan 2009 22:11:52 -0000 1.6
***************
*** 410,413 ****
--- 410,414 ----
RUNTIME_CLASS(CView),
sizeof(PyCView),
+ PYOBJ_OFFSET(PyCView),
PyCView_methods,
NULL);
***************
*** 626,629 ****
--- 627,631 ----
RUNTIME_CLASS(CScrollView),
sizeof(PyCScrollView),
+ PYOBJ_OFFSET(PyCScrollView),
PyCScrollView_methods,
GET_PY_CTOR(PyCScrollView));
***************
*** 684,704 ****
RUNTIME_CLASS(CCtrlView),
sizeof(PyCCtrlView),
PyCCtrlView_methods,
GET_PY_CTOR(PyCCtrlView));
- /* Implement an psuedo-inheritance for ControlView */
- PyObject *
- PyCCtrlView::getattr(char *name)
- {
- // implement inheritance.
- PyObject *retMethod = PyCView::getattr(name);
- if (!retMethod) {
- PyErr_Clear();
- PyCCtrlView_Type *thisType = (PyCCtrlView_Type *)ob_type;
- if (thisType)
- retMethod = Py_FindMethod(thisType->control->methods, (PyObject *)this, name);
- }
- return retMethod;
- }
/////////////////////////////////////////////////////////////////////
--- 686,693 ----
RUNTIME_CLASS(CCtrlView),
sizeof(PyCCtrlView),
+ PYOBJ_OFFSET(PyCCtrlView),
PyCCtrlView_methods,
GET_PY_CTOR(PyCCtrlView));
/////////////////////////////////////////////////////////////////////
***************
*** 940,944 ****
// @base PyCEditView|PyCCtrlView
! PyCCtrlView_Type PyCEditView::type("PyCEditView", &PyCCtrlView::type, &PyCEdit::type, RUNTIME_CLASS(CEditView), sizeof(PyCEditView), ui_edit_window_methods, GET_PY_CTOR(PyCEditView));
/////////////////////////////////////////////////////////////////////
--- 929,940 ----
// @base PyCEditView|PyCCtrlView
! PyCCtrlView_Type PyCEditView::type("PyCEditView",
! &PyCCtrlView::type,
! &PyCEdit::type,
! RUNTIME_CLASS(CEditView),
! sizeof(PyCEditView),
! PYOBJ_OFFSET(PyCEditView),
! ui_edit_window_methods,
! GET_PY_CTOR(PyCEditView));
/////////////////////////////////////////////////////////////////////
***************
*** 1021,1024 ****
--- 1017,1021 ----
RUNTIME_CLASS(CListView),
sizeof(PyCListView),
+ PYOBJ_OFFSET(PyCListView),
ui_list_view_methods,
GET_PY_CTOR(PyCListView));
***************
*** 1102,1105 ****
--- 1099,1103 ----
RUNTIME_CLASS(CTreeView),
sizeof(PyCTreeView),
+ PYOBJ_OFFSET(PyCTreeView),
ui_tree_view_methods,
GET_PY_CTOR(PyCTreeView));
***************
*** 1163,1166 ****
--- 1161,1165 ----
RUNTIME_CLASS(CFormView),
sizeof(PyCFormView),
+ PYOBJ_OFFSET(PyCFormView),
PyCFormView_methods,
GET_PY_CTOR(PyCFormView));
Index: win32rgn.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32rgn.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** win32rgn.cpp 1 Jul 2002 15:09:40 -0000 1.2
--- win32rgn.cpp 8 Jan 2009 22:11:52 -0000 1.3
***************
*** 180,183 ****
--- 180,184 ----
RUNTIME_CLASS(CRgn),
sizeof(PyCRgn),
+ PYOBJ_OFFSET(PyCRgn),
PyCRgn_methods,
GET_PY_CTOR(PyCRgn));
Index: win32dlg.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32dlg.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** win32dlg.cpp 4 Dec 2008 00:17:13 -0000 1.12
--- win32dlg.cpp 8 Jan 2009 22:11:52 -0000 1.13
***************
*** 175,207 ****
}
- PyCWnd::DoKillAssoc(TRUE);
ui_assoc_object::SetAssocInvalid(); // must call this explicitely, as I ignore SetAssocInvalid
! Py_XDECREF(ddlist);
! Py_XDECREF(dddict);
! }
! void PyCDialog::DoKillAssoc(BOOL bDestructing /*=FALSE*/ )
! {
! // we can not have the pointer deleted at window destruction time
// for a dialog (as MFC still needs it after the dialog has completed
BOOL bManDeleteSave = bManualDelete;
! if (!bDestructing)
! bManualDelete = FALSE;
! PyCWnd::DoKillAssoc(bDestructing);
! if (!bDestructing)
! bManualDelete = bManDeleteSave;
}
PyObject *
! PyCDialog::getattr(char *name)
{
if (strcmp(name,"data")==0) {
Py_INCREF(dddict);
return dddict;
! }
! else if (strcmp(name,"datalist")==0) {
Py_INCREF(ddlist);
return ddlist;
! }
! else
! return ui_base_class::getattr(name);
}
--- 175,198 ----
}
ui_assoc_object::SetAssocInvalid(); // must call this explicitely, as I ignore SetAssocInvalid
! Py_XDECREF(ddlist); // we can not have the pointer deleted at window destruction time
// for a dialog (as MFC still needs it after the dialog has completed
BOOL bManDeleteSave = bManualDelete;
! Py_XDECREF(dddict);
}
+
PyObject *
! PyCDialog::getattro(PyObject *obname)
{
+ char *name=PYWIN_ATTR_CONVERT(obname);
if (strcmp(name,"data")==0) {
Py_INCREF(dddict);
return dddict;
! }
! if (strcmp(name,"datalist")==0) {
Py_INCREF(ddlist);
return ddlist;
! }
! return PyObject_GenericGetAttr(this, obname);
}
***************
*** 216,219 ****
--- 207,211 ----
static PyObject *do_exchange_edit( int id, int index, char *type, PyObject *oldVal, PyObject *o1, PyObject *o2, CDataExchange *pDX )
{
+ // Note use of funky exception handlers to ensure thread-state remains correct even when MFC exception is thrown.
PyObject *newOb;
switch (type[0]) {
***************
*** 222,228 ****
if (oldVal)
intVal = (int)PyInt_AsLong(oldVal);
! GUI_BGN_SAVE;
! DDX_Text(pDX, id, intVal);
! GUI_END_SAVE;
if (o1 && o2) {
if (PyInt_Check(o1) && PyInt_Check(o2))
--- 214,229 ----
if (oldVal)
intVal = (int)PyInt_AsLong(oldVal);
! PyThreadState *_save = PyEval_SaveThread();
! TRY
! {
! DDX_Text(pDX, id, intVal);
! PyEval_RestoreThread(_save);
! }
! CATCH_ALL(e)
! {
! PyEval_RestoreThread(_save);
! THROW(e);
! }
! END_CATCH_ALL
if (o1 && o2) {
if (PyInt_Check(o1) && PyInt_Check(o2))
***************
*** 245,251 ****
csVal=_T("");
}
! GUI_BGN_SAVE;
! DDX_Text(pDX, id, csVal);
! GUI_END_SAVE;
if (o1 && o2) {
if (PyInt_Check(o1) && o2==NULL)
--- 246,261 ----
csVal=_T("");
}
! PyThreadState *_save = PyEval_SaveThread();
! TRY
! {
! DDX_Text(pDX, id, csVal);
! PyEval_RestoreThread(_save);
! }
! CATCH_ALL(e)
! {
! PyEval_RestoreThread(_save);
! THROW(e);
! }
! END_CATCH_ALL
if (o1 && o2) {
if (PyInt_Check(o1) && o2==NULL)
***************
*** 400,404 ****
{
CEnterLeavePython _celp;
! PyCDialog *dob = (PyCDialog *) ui_assoc_object::GetPyObject(pDlg);
if (!dob) {
TRACE("do_exchange called on dialog with no Python object!\n");
--- 410,414 ----
{
CEnterLeavePython _celp;
! PyCDialog *dob = (PyCDialog *) ui_assoc_object::GetAssocObject(pDlg);
if (!dob) {
TRACE("do_exchange called on dialog with no Python object!\n");
***************
*** 447,450 ****
--- 457,461 ----
if (PyErr_Occurred())
gui_print_error();
+ Py_DECREF(dob);
}
***************
*** 732,735 ****
--- 743,747 ----
RUNTIME_CLASS(CDialog),
sizeof(PyCDialog),
+ PYOBJ_OFFSET(PyCDialog),
ui_dialog_methods,
GET_PY_CTOR(PyCDialog));
***************
*** 744,747 ****
--- 756,760 ----
NULL, // CCommonDialog doesnt have RTTI???
sizeof(PyCCommonDialog),
+ PYOBJ_OFFSET(PyCCommonDialog),
ui_common_dialog_methods,
NULL);
***************
*** 966,969 ****
--- 979,983 ----
RUNTIME_CLASS(CFileDialog),
sizeof(PyCFileDialog),
+ PYOBJ_OFFSET(PyCFileDialog),
ui_file_dialog_methods,
GET_PY_CTOR(PyCFileDialog));
***************
*** 1175,1178 ****
--- 1189,1193 ----
RUNTIME_CLASS(CFontDialog),
sizeof(PyCFontDialog),
+ PYOBJ_OFFSET(PyCFontDialog),
ui_font_dialog_methods,
GET_PY_CTOR(PyCFontDialog));
***************
*** 1332,1335 ****
--- 1347,1351 ----
RUNTIME_CLASS(CColorDialog),
sizeof(PyCColorDialog),
+ PYOBJ_OFFSET(PyCColorDialog),
ui_color_dialog_methods,
GET_PY_CTOR(PyCColorDialog));
***************
*** 1436,1439 ****
--- 1452,1456 ----
RUNTIME_CLASS(CPrintDialog),
sizeof(PyCPrintDialog),
+ PYOBJ_OFFSET(PyCPrintDialog),
ui_print_dialog_methods,
GET_PY_CTOR(PyCPrintDialog));
Index: win32ctrlTree.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32ctrlTree.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** win32ctrlTree.cpp 13 Nov 2008 04:04:50 -0000 1.7
--- win32ctrlTree.cpp 8 Jan 2009 22:11:52 -0000 1.8
***************
*** 857,860 ****
--- 857,861 ----
RUNTIME_CLASS(CTreeCtrl),
sizeof(PyCTreeCtrl),
+ PYOBJ_OFFSET(PyCTreeCtrl),
PyCTreeCtrl_methods,
GET_PY_CTOR(PyCTreeCtrl));
Index: win32virt.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32virt.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** win32virt.cpp 6 Dec 2008 00:35:20 -0000 1.8
--- win32virt.cpp 8 Jan 2009 22:11:52 -0000 1.9
***************
*** 19,23 ****
extern BOOL bInFatalShutdown;
! CVirtualHelper::CVirtualHelper(const char *iname, const void *iassoc, EnumVirtualErrorHandling veh/* = VEH_PRINT_ERROR */)
{
handler=NULL;
--- 19,23 ----
extern BOOL bInFatalShutdown;
! CVirtualHelper::CVirtualHelper(const char *iname, void *iassoc, EnumVirtualErrorHandling veh/* = VEH_PRINT_ERROR */)
{
handler=NULL;
***************
*** 26,35 ****
csHandlerName = iname;
vehErrorHandling = veh;
! ui_assoc_object *py_bob = ui_assoc_object::handleMgr.GetAssocObject( iassoc );
! if (bInFatalShutdown || py_bob==NULL)
return;
CEnterLeavePython _celp;
if (!py_bob->is_uiobject( &ui_assoc_object::type)) {
TRACE("CVirtualHelper::CVirtualHelper Error: Call object is not of required type\n");
return;
}
--- 26,38 ----
csHandlerName = iname;
vehErrorHandling = veh;
! if (bInFatalShutdown)
return;
CEnterLeavePython _celp;
+ ui_assoc_object *py_bob = ui_assoc_object::handleMgr.GetAssocObject( iassoc );
+ if (py_bob==NULL)
+ return;
if (!py_bob->is_uiobject( &ui_assoc_object::type)) {
TRACE("CVirtualHelper::CVirtualHelper Error: Call object is not of required type\n");
+ Py_DECREF(py_bob);
return;
}
***************
*** 53,58 ****
}
py_ob = py_bob;
! Py_INCREF(py_ob);
}
CVirtualHelper::~CVirtualHelper()
{
--- 56,62 ----
}
py_ob = py_bob;
! // reference on 'py_bob' now owned by 'py_ob'
}
+
CVirtualHelper::~CVirtualHelper()
{
Index: win32splitter.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32splitter.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** win32splitter.cpp 13 Nov 2008 04:04:50 -0000 1.3
--- win32splitter.cpp 8 Jan 2009 22:11:52 -0000 1.4
***************
*** 246,249 ****
--- 246,250 ----
RUNTIME_CLASS(CSplitterWnd),
sizeof(PyCSplitterWnd),
+ PYOBJ_OFFSET(PyCSplitterWnd),
ui_splitter_window_methods,
GET_PY_CTOR(PyCSplitterWnd));
Index: ddeconv.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/ddeconv.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ddeconv.cpp 6 Dec 2008 00:34:06 -0000 1.3
--- ddeconv.cpp 8 Jan 2009 22:11:52 -0000 1.4
***************
*** 131,134 ****
--- 131,135 ----
RUNTIME_CLASS(CDDEConv),
sizeof(PyDDEConv),
+ PYOBJ_OFFSET(PyDDEConv),
PyDDEConv_methods,
GET_PY_CTOR(PyDDEConv));
Index: win32thread.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32thread.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** win32thread.cpp 13 Nov 2008 04:04:50 -0000 1.10
--- win32thread.cpp 8 Jan 2009 22:11:52 -0000 1.11
***************
*** 331,334 ****
--- 331,335 ----
RUNTIME_CLASS(CWinThread),
sizeof(PyCWinThread),
+ PYOBJ_OFFSET(PyCWinThread),
PyCWinThread_methods,
GET_PY_CTOR(PyCWinThread) );
Index: win32doc.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32doc.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** win32doc.cpp 13 Nov 2008 04:04:50 -0000 1.6
--- win32doc.cpp 8 Jan 2009 22:11:52 -0000 1.7
***************
*** 443,446 ****
--- 443,447 ----
RUNTIME_CLASS(CDocument),
sizeof(PyCDocument),
+ PYOBJ_OFFSET(PyCDocument),
ui_doc_methods,
GET_PY_CTOR(PyCDocument) );
Index: win32prop.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32prop.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** win32prop.cpp 13 Nov 2008 04:04:50 -0000 1.4
--- win32prop.cpp 8 Jan 2009 22:11:52 -0000 1.5
***************
*** 106,122 ****
{
}
- /********
- TRACE("PropSheet object destructing\n");
- CPythonPropertySheet *pSheet = GetPythonPropSheet(this);
- ASSERT(pSheet);
- PyCWnd::DoKillAssoc(TRUE);
- ui_assoc_object::SetAssocInvalid(); // must call this explicitely, as I ignore SetAssocInvalid
- }
-
- void PyCPropertySheet::DoKillAssoc(BOOL bDestructing )
- {
- return;
- }
- *************/
// @pymethod <o PyCPropertySheet>|win32ui|CreatePropertySheet|Creates a property sheet object.
PyObject *PyCPropertySheet::create( PyObject *self, PyObject *args )
--- 106,109 ----
***************
*** 581,584 ****
--- 568,572 ----
RUNTIME_CLASS(CPropertySheet),
sizeof(PyCPropertySheet),
+ PYOBJ_OFFSET(PyCPropertySheet),
ui_propsheet_methods,
GET_PY_CTOR(PyCPropertySheet));
***************
*** 862,865 ****
--- 850,854 ----
RUNTIME_CLASS(CPropertyPage),
sizeof(PyCPropertyPage),
+ PYOBJ_OFFSET(PyCPropertyPage),
ui_proppage_methods,
GET_PY_CTOR(PyCPropertyPage));
***************
*** 938,941 ****
--- 927,931 ----
RUNTIME_CLASS(CTabCtrl),
sizeof(ui_tabctrl_object),
+ PYOBJ_OFFSET(ui_tabctrl_object),
ui_tabctrl_methods,
GET_PY_CTOR(ui_tabctrl_object));
Index: win32notify.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32notify.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** win32notify.cpp 13 Nov 2008 04:04:50 -0000 1.8
--- win32notify.cpp 8 Jan 2009 22:11:52 -0000 1.9
***************
*** 240,250 ****
Python_OnNotify (CWnd *pFrom, WPARAM, LPARAM lParam, LRESULT *pResult)
{
- CEnterLeavePython _celp;
- PyCCmdTarget *pPyWnd = (PyCCmdTarget *) ui_assoc_CObject::GetPyObject(pFrom);
NMHDR *pHdr = (NMHDR *)lParam;
-
if (pHdr==NULL)
return FALSE; // bad data passed?
UINT code = pHdr->code;
if (pPyWnd==NULL) return FALSE; // no object.
--- 240,249 ----
Python_OnNotify (CWnd *pFrom, WPARAM, LPARAM lParam, LRESULT *pResult)
{
NMHDR *pHdr = (NMHDR *)lParam;
if (pHdr==NULL)
return FALSE; // bad data passed?
UINT code = pHdr->code;
+ CEnterLeavePython _celp;
+ PyCCmdTarget *pPyWnd = (PyCCmdTarget *) ui_assoc_CObject::GetAssocObject(pFrom);
if (pPyWnd==NULL) return FALSE; // no object.
***************
*** 253,258 ****
if (!pPyWnd->pNotifyHookList ||
! !pPyWnd->pNotifyHookList->Lookup (code, (void *&)method))
return FALSE; // no hook installed.
// have method to call. Build arguments.
--- 252,260 ----
if (!pPyWnd->pNotifyHookList ||
! !pPyWnd->pNotifyHookList->Lookup (code, (void *&)method)) {
! Py_DECREF(pPyWnd);
return FALSE; // no hook installed.
+ }
+ Py_DECREF(pPyWnd);
// have method to call. Build arguments.
Index: win32oleDlgInsert.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32oleDlgInsert.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** win32oleDlgInsert.cpp 13 Nov 2008 04:04:50 -0000 1.2
--- win32oleDlgInsert.cpp 8 Jan 2009 22:11:52 -0000 1.3
***************
*** 217,220 ****
--- 217,221 ----
RUNTIME_CLASS(COleInsertDialog),
sizeof(PyCOleInsertDialog),
+ PYOBJ_OFFSET(PyCOleInsertDialog),
PyCOleInsertDialog_methods,
GET_PY_CTOR(PyCOleInsertDialog) );
Index: win32font.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32font.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** win32font.cpp 3 Jun 2007 12:35:58 -0000 1.4
--- win32font.cpp 8 Jan 2009 22:11:52 -0000 1.5
***************
*** 62,66 ****
}
}
! return ui_assoc_object::make (PyCFont::type, pFont);
}
--- 62,69 ----
}
}
! PyCFont *ret = (PyCFont *)ui_assoc_object::make (PyCFont::type, pFont, TRUE);
! if (ret)
! ret->bManualDelete = TRUE;
! return ret;
}
***************
*** 87,90 ****
--- 90,94 ----
RUNTIME_CLASS(CFont),
sizeof(PyCFont),
+ PYOBJ_OFFSET(PyCFont),
ui_font_methods,
GET_PY_CTOR(PyCFont));
Index: win32assoc.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32assoc.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** win32assoc.h 7 Sep 2004 02:26:20 -0000 1.2
--- win32assoc.h 8 Jan 2009 22:11:52 -0000 1.3
***************
*** 23,35 ****
CAssocManager();
~CAssocManager();
! void Assoc(void *assoc, ui_assoc_object *PyObject, void *oldAssoc=NULL);
! ui_assoc_object *GetAssocObject(const void * handle);
void cleanup(void); // only to be called at the _very_ end
private:
CMapPtrToPtr map;
const void *lastLookup;
! ui_assoc_object *lastObject;
! CCriticalSection m_critsec;
#ifdef _DEBUG
int cacheLookups;
--- 23,37 ----
CAssocManager();
~CAssocManager();
! void Assoc(void *assoc, ui_assoc_object *PyObject);
! ui_assoc_object *GetAssocObject(void * handle);
void cleanup(void); // only to be called at the _very_ end
private:
+ void RemoveAssoc(void *handle);
+ // A "map" of weak-references to Python objects. Now we use weakrefs
+ // this really should be a regular Python dict...
CMapPtrToPtr map;
const void *lastLookup;
! PyObject *lastObjectWeakRef;
#ifdef _DEBUG
int cacheLookups;
***************
*** 47,51 ****
// Given a C++ object, return a PyObject associated (map lookup)
! static ui_assoc_object *GetPyObject(void *search);
// Return the C++ object associated with this Python object.
--- 49,55 ----
// Given a C++ object, return a PyObject associated (map lookup)
! static ui_assoc_object *GetAssocObject(void *search) {
! return ui_assoc_object::handleMgr.GetAssocObject(search);
! }
// Return the C++ object associated with this Python object.
***************
*** 55,61 ****
static void *GetGoodCppObject(PyObject *&self, ui_type *ui_type_check);
- // Call this when the C++ object dies, or otherwise becomes invalid.
- void KillAssoc(); // maps to a virtual with some protection wrapping.
-
// virtuals for Python support
virtual CString repr();
--- 59,62 ----
***************
*** 74,83 ****
void *GetGoodCppObject(ui_type *ui_type_check=NULL) const;
virtual bool CheckCppObject(ui_type *ui_type_check) const {return true;}
! // Does the actual killing.
! virtual void DoKillAssoc( BOOL bDestructing = FALSE ); // does the actual work.
! // Called during KillAssoc - normally zeroes association.
! // Override to keep handle after destruction (eg, the association
! // with a dialog is valid after the Window's window has closed).
! virtual void SetAssocInvalid() { assoc = 0; }
ui_assoc_object(); // ctor/dtor
--- 75,79 ----
void *GetGoodCppObject(ui_type *ui_type_check=NULL) const;
virtual bool CheckCppObject(ui_type *ui_type_check) const {return true;}
! virtual void SetAssocInvalid() { assoc = 0; } // XXX - bogus - called during destruction???
ui_assoc_object(); // ctor/dtor
Index: win32control.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32control.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** win32control.cpp 13 Nov 2008 04:04:50 -0000 1.7
--- win32control.cpp 8 Jan 2009 22:11:52 -0000 1.8
***************
*** 59,62 ****
--- 59,63 ----
RUNTIME_CLASS(CObject),
sizeof(ui_control_object),
+ PYOBJ_OFFSET(ui_control_object),
ui_control_object_methods,
NULL);
***************
*** 265,268 ****
--- 266,270 ----
RUNTIME_CLASS(CButton),
sizeof(PyCButton),
+ PYOBJ_OFFSET(PyCButton),
PyCButton_methods,
GET_PY_CTOR(PyCButton));
***************
*** 879,882 ****
--- 881,885 ----
RUNTIME_CLASS(CListBox),
sizeof(PyCListBox),
+ PYOBJ_OFFSET(PyCListBox),
PyCListBox_methods,
GET_PY_CTOR(PyCListBox));
***************
*** 1317,1320 ****
--- 1320,1324 ----
RUNTIME_CLASS(CComboBox),
sizeof(PyCComboBox),
+ PYOBJ_OFFSET(PyCComboBox),
PyCComboBox_methods,
GET_PY_CTOR(PyCComboBox));
***************
*** 1476,1479 ****
--- 1480,1484 ----
RUNTIME_CLASS(CProgressCtrl),
sizeof(PyCProgressCtrl),
+ PYOBJ_OFFSET(PyCProgressCtrl),
PyCProgressCtrl_methods,
GET_PY_CTOR(PyCProgressCtrl));
***************
*** 1991,1994 ****
--- 1996,2000 ----
RUNTIME_CLASS(CSliderCtrl),
sizeof(PyCSliderCtrl),
+ PYOBJ_OFFSET(PyCSliderCtrl),
PyCSliderCtrl_methods,
GET_PY_CTOR(PyCSliderCtrl));
***************
*** 2438,2441 ****
--- 2444,2448 ----
RUNTIME_CLASS(CStatusBarCtrl),
sizeof(PyCStatusBarCtrl),
+ PYOBJ_OFFSET(PyCStatusBarCtrl),
PyCStatusBarCtrl_methods,
GET_PY_CTOR(PyCStatusBarCtrl));
***************
*** 2526,2529 ****
--- 2533,2537 ----
RUNTIME_CLASS(CSpinButtonCtrl),
sizeof(PyCSpinButtonCtrl),
+ PYOBJ_OFFSET(PyCSpinButtonCtrl),
PyCSpinButtonCtrl_methods,
GET_PY_CTOR(PyCSpinButtonCtrl));
Index: win32pen.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32pen.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** win32pen.cpp 1 Sep 1999 23:33:02 -0000 1.1
--- win32pen.cpp 8 Jan 2009 22:11:52 -0000 1.2
***************
*** 53,56 ****
--- 53,57 ----
RUNTIME_CLASS(CPen),
sizeof(ui_pen_object),
+ PYOBJ_OFFSET(ui_pen_object),
ui_pen_methods,
GET_PY_CTOR(ui_pen_object));
Index: win32ctrlList.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32ctrlList.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** win32ctrlList.cpp 13 Nov 2008 04:04:50 -0000 1.4
--- win32ctrlList.cpp 8 Jan 2009 22:11:52 -0000 1.5
***************
*** 835,838 ****
--- 835,839 ----
RUNTIME_CLASS(CListCtrl),
sizeof(PyCListCtrl),
+ PYOBJ_OFFSET(PyCListCtrl),
PyCListCtrl_methods,
GET_PY_CTOR(PyCListCtrl));
Index: win32gdi.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32gdi.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** win32gdi.h 1 Sep 1999 23:33:02 -0000 1.1
--- win32gdi.h 8 Jan 2009 22:11:52 -0000 1.2
***************
*** 16,30 ****
static CBitmap *GetBitmap (PyObject *self) { return (CBitmap *)GetGdiObject(self, OBJ_BITMAP); }
CBitmap *GetBitmap() { return GetBitmap (this); }
- BOOL m_deleteObject;
protected:
PyCGdiObject()
- : m_deleteObject(TRUE)
{ }
~PyCGdiObject();
- virtual void DoKillAssoc( BOOL bDestructing = FALSE );
virtual bool CheckCppObject(ui_type *ui_type_check) const;
! // virtuals for the Python interface.
! virtual CString repr();
};
--- 16,30 ----
static CBitmap *GetBitmap (PyObject *self) { return (CBitmap *)GetGdiObject(self, OBJ_BITMAP); }
CBitmap *GetBitmap() { return GetBitmap (this); }
protected:
PyCGdiObject()
{ }
~PyCGdiObject();
virtual bool CheckCppObject(ui_type *ui_type_check) const;
! // XXX - PyCGDIObject used to have an 'm_deleteObject' attribute - but all
! // it did was cause a normal 'delete' of the object - ie, identical to the
! // base-class bManualDelete. Its likely the original intent was for the new
! // attribute to determine if ::DeleteObject() should have been called, but
! // that apparently has never happened...
};
Index: win32RichEdit.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32RichEdit.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** win32RichEdit.cpp 13 Nov 2008 04:04:50 -0000 1.3
--- win32RichEdit.cpp 8 Jan 2009 22:11:52 -0000 1.4
***************
*** 83,86 ****
--- 83,87 ----
RUNTIME_CLASS(CRichEditDoc),
sizeof(PyCRichEditDoc),
+ PYOBJ_OFFSET(PyCRichEditDoc),
PyCRichEditDoc_methods,
GET_PY_CTOR(PyCRichEditDoc) );
***************
*** 227,230 ****
};
! PyCCtrlView_Type PyCRichEditView::type("PyCRichEditView", &PyCCtrlView::type, &PyCRichEditCtrl::type, RUNTIME_CLASS(CRichEditView), sizeof(PyCRichEditView), PyCRichEditView_methods, GET_PY_CTOR(PyCRichEditView));
--- 228,238 ----
};
! PyCCtrlView_Type PyCRichEditView::type("PyCRichEditView",
! &PyCCtrlView::type,
! &PyCRichEditCtrl::type,
! RUNTIME_CLASS(CRichEditView),
! sizeof(PyCRichEditView),
! PYOBJ_OFFSET(PyCRichEditView),
! PyCRichEditView_methods,
! GET_PY_CTOR(PyCRichEditView));
Index: win32prinfo.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32prinfo.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** win32prinfo.h 28 Oct 1999 01:38:31 -0000 1.2
--- win32prinfo.h 8 Jan 2009 22:11:52 -0000 1.3
***************
*** 5,9 ****
~ui_prinfo_object();
virtual void SetAssocInvalid();
- virtual void DoKillAssoc( BOOL bDestructing = FALSE );
virtual void *GetGoodCppObject(ui_type *ui_type_check=NULL) const;
--- 5,8 ----
Index: win32dlgbar.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32dlgbar.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** win32dlgbar.cpp 13 Nov 2008 04:04:50 -0000 1.2
--- win32dlgbar.cpp 8 Jan 2009 22:11:52 -0000 1.3
***************
*** 85,88 ****
--- 85,89 ----
RUNTIME_CLASS(CDialogBar),
sizeof(PyCDialogBar),
+ PYOBJ_OFFSET(PyCDialogBar),
PyCDialogBar_methods,
GET_PY_CTOR(PyCDialogBar));
Index: win32uioleClientItem.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uioleClientItem.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** win32uioleClientItem.cpp 13 Nov 2008 04:04:50 -0000 1.2
--- win32uioleClientItem.cpp 8 Jan 2009 22:11:52 -0000 1.3
***************
*** 370,373 ****
--- 370,374 ----
RUNTIME_CLASS(COleClientItem),
sizeof(PyCOleClientItem),
+ PYOBJ_OFFSET(PyCOleClientItem),
PyCOleClientItem_methods,
GET_PY_CTOR(PyCOleClientItem) );
Index: win32dll.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32dll.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** win32dll.h 1 Sep 1999 23:33:01 -0000 1.1
--- win32dll.h 8 Jan 2009 22:11:52 -0000 1.2
***************
*** 15,19 ****
dll_object();
~dll_object();
- virtual void DoKillAssoc( BOOL bDestructing = FALSE );
virtual CString repr();
private:
--- 15,18 ----
Index: win32cmd.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32cmd.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** win32cmd.h 1 Sep 1999 23:33:00 -0000 1.1
--- win32cmd.h 8 Jan 2009 22:11:52 -0000 1.2
***************
*** 8,12 ****
//
class PYW_EXPORT PyCCmdTarget : public ui_assoc_CObject{
! friend CVirtualHelper::CVirtualHelper(const char *iname, const void *iassoc, EnumVirtualErrorHandling veh);
public: // some probably shouldnt be, but...
CMapWordToPtr *pNotifyHookList;
--- 8,12 ----
//
class PYW_EXPORT PyCCmdTarget : public ui_assoc_CObject{
! friend CVirtualHelper::CVirtualHelper(const char *iname, void *iassoc, EnumVirtualErrorHandling veh);
public: // some probably shouldnt be, but...
CMapWordToPtr *pNotifyHookList;
***************
*** 15,20 ****
CMapWordToPtr *pCommandUpdateHookList;
- virtual void DoKillAssoc( BOOL bDestructing = FALSE );
-
// virtuals for Python support
virtual CString repr();
--- 15,18 ----
Index: win32brush.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32brush.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** win32brush.cpp 3 Jun 2007 12:35:57 -0000 1.2
--- win32brush.cpp 8 Jan 2009 22:11:52 -0000 1.3
***************
*** 26,31 ****
PyObject *ui_get_halftone_brush(PyObject *self, PyObject *args)
{
! PyCBrush *pb = (PyCBrush *)ui_assoc_object::make (PyCBrush::type, CDC::GetHalftoneBrush());
! pb->m_deleteObject = FALSE; // this is a temp object
return pb;
}
--- 26,31 ----
PyObject *ui_get_halftone_brush(PyObject *self, PyObject *args)
{
! PyCBrush *pb = (PyCBrush *)ui_assoc_object::make (PyCBrush::type, CDC::GetHalftoneBrush(), true);
! pb->bManualDelete = FALSE; // this is a temp object
return pb;
}
***************
*** 39,46 ****
long cr_color;
LOGBRUSH lp;
! // Quick exist to make a empty brush
if (PyArg_ParseTuple(args, "")) {
// @comm If called with no arguments, an uninitialized brush is created.
! return ui_assoc_object::make (PyCBrush::type, new CBrush);
}
PyErr_Clear();
--- 39,48 ----
long cr_color;
LOGBRUSH lp;
! // Quick exit to make a empty brush
if (PyArg_ParseTuple(args, "")) {
// @comm If called with no arguments, an uninitialized brush is created.
! PyCBrush *ret = (PyCBrush *)ui_assoc_object::make (PyCBrush::type, new CBrush);
! ret->bManualDelete = TRUE;
! return ret;
}
PyErr_Clear();
***************
*** 59,63 ****
RETURN_ERR ("CreateBrushIndirect call failed");
}
! return ui_assoc_object::make (PyCBrush::type, pBrush);
}
--- 61,67 ----
RETURN_ERR ("CreateBrushIndirect call failed");
}
! PyCBrush *ret = (PyCBrush *)ui_assoc_object::make (PyCBrush::type, pBrush);
! ret->bManualDelete = TRUE;
! return ret;
}
***************
*** 95,98 ****
--- 99,103 ----
RUNTIME_CLASS(CBrush),
sizeof(PyCBrush),
+ PYOBJ_OFFSET(PyCBrush),
PyCBrush_methods,
GET_PY_CTOR(PyCBrush));
Index: dllmain.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/dllmain.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** dllmain.cpp 13 Nov 2008 04:04:50 -0000 1.6
--- dllmain.cpp 8 Jan 2009 22:11:52 -0000 1.7
***************
*** 212,216 ****
// could not have been created. Let the Python code manage if it wants!
Win32uiFinalize();
- Python_delete_assoc(pCreatedApp); // so Python wont try and use it.
AfxWinTerm();
afxCurrentWinApp = NULL; // So AfxGetApp fails from here.
--- 212,215 ----
Index: win32win.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32win.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** win32win.h 13 Nov 2008 04:04:50 -0000 1.4
--- win32win.h 8 Jan 2009 22:11:52 -0000 1.5
***************
*** 17,21 ****
PyCWnd();
~PyCWnd();
- virtual void DoKillAssoc( BOOL bDestructing = FALSE );
public:
static CWnd *GetPythonGenericWnd(PyObject *self, ui_type_CObject *pType = &type);
--- 17,20 ----
Index: ddetopic.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/ddetopic.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ddetopic.cpp 10 Nov 2003 04:39:44 -0000 1.1
--- ddetopic.cpp 8 Jan 2009 22:11:52 -0000 1.2
***************
*** 55,58 ****
--- 55,59 ----
RUNTIME_CLASS(CDDETopic),
sizeof(PyDDETopic),
+ PYOBJ_OFFSET(PyDDETopic),
PyDDETopic_methods,
GET_PY_CTOR(PyDDETopic));
***************
*** 73,76 ****
--- 74,78 ----
RUNTIME_CLASS(CDDEServerSystemTopic),
sizeof(PyDDEServerSystemTopic),
+ PYOBJ_OFFSET(PyDDEServerSystemTopic),
PyDDEServerSystemTopic_methods,
GET_PY_CTOR(PyDDEServerSystemTopic));
Index: win32template.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32template.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** win32template.cpp 13 Nov 2008 04:04:50 -0000 1.5
--- win32template.cpp 8 Jan 2009 22:11:52 -0000 1.6
***************
*** 43,48 ****
return; // no more to do.
RemoveDocTemplateFromApp(pTemp);
- delete pTemp;
- SetAssocInvalid();
}
--- 43,46 ----
***************
*** 413,416 ****
--- 411,415 ----
RUNTIME_CLASS(CDocTemplate),
sizeof(PyCDocTemplate),
+ PYOBJ_OFFSET(PyCDocTemplate),
PyCDocTemplate_methods,
GET_PY_CTOR(PyCDocTemplate) );
Index: win32dll.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32dll.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** win32dll.cpp 13 Nov 2008 04:04:50 -0000 1.2
--- win32dll.cpp 8 Jan 2009 22:11:52 -0000 1.3
***************
*** 22,28 ****
dll_object::~dll_object()
{
! if (bDidLoadLibrary)
! dll_object::DoKillAssoc(TRUE); // must explicitly call, as virtuals dont work in dtors!
}
// @pymethod <o PyDLL>|win32ui|LoadLibrary|Creates a DLL object, and loads a Windows DLL into the object.
PyObject *
--- 22,37 ----
dll_object::~dll_object()
{
! if (bDidLoadLibrary = TRUE) {
! ::FreeLibrary (GetDll());
! TRACE("Python object freeing DLL reference\n");
! }
! if (pMFCExt) {
! AfxTermExtensionModule(*pMFCExt); // this deletes the DLL.
! delete pMFCExt;
! pMFCExt = NULL;
! pCDLL = NULL;
! }
}
+
// @pymethod <o PyDLL>|win32ui|LoadLibrary|Creates a DLL object, and loads a Windows DLL into the object.
PyObject *
***************
*** 62,79 ****
return ret;
}
- void dll_object::DoKillAssoc( BOOL bDestructing /*= FALSE*/ )
- {
- if (bDidLoadLibrary = TRUE) {
- ::FreeLibrary (GetDll());
- TRACE("Python object freeing DLL reference\n");
- ui_assoc_object::DoKillAssoc(bDestructing);
- }
- if (pMFCExt) {
- AfxTermExtensionModule(*pMFCExt); // this deletes the DLL.
- delete pMFCExt;
- pMFCExt = NULL;
- pCDLL = NULL;
- }
- }
// @pymethod |PyDLL|AttachToMFC|Attaches the DLL object to the MFC list of DLL's.
// @comm After calling this method, MFC will search this DLL when looking for resources.
--- 71,74 ----
***************
*** 151,154 ****
--- 146,150 ----
&ui_assoc_object::type,
sizeof(dll_object),
+ PYOBJ_OFFSET(dll_object),
dll_methods,
GET_PY_CTOR(dll_object));
Index: ddeserver.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/ddeserver.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ddeserver.cpp 13 Nov 2008 04:04:50 -0000 1.2
--- ddeserver.cpp 8 Jan 2009 22:11:52 -0000 1.3
***************
*** 142,145 ****
--- 142,146 ----
RUNTIME_CLASS(CDDEServer),
sizeof(PyDDEServer),
+ PYOBJ_OFFSET(PyDDEServer),
PyDDEServer_methods,
GET_PY_CTOR(PyDDEServer));
Index: win32prop.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32prop.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** win32prop.h 1 Sep 1999 23:33:02 -0000 1.1
--- win32prop.h 8 Jan 2009 22:11:52 -0000 1.2
***************
*** 16,22 ****
PyCPropertySheet();
virtual ~PyCPropertySheet();
-
- // virtual void DoKillAssoc( BOOL bDestructing=FALSE);
- // virtual void SetAssocInvalid() {return; }//ignore
};
--- 16,19 ----
Index: win32dlg.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32dlg.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** win32dlg.h 13 Nov 2008 04:04:50 -0000 1.2
--- win32dlg.h 8 Jan 2009 22:11:52 -0000 1.3
***************
*** 21,28 ****
PyCDialog();
virtual ~PyCDialog();
- virtual void DoKillAssoc( BOOL bDestructing=FALSE);
virtual void SetAssocInvalid() {return; }//ignore
public:
! virtual PyObject *getattr(char *name);
};
////////////////////////////////////////////////////////
--- 21,27 ----
PyCDialog();
virtual ~PyCDialog();
virtual void SetAssocInvalid() {return; }//ignore
public:
! virtual PyObject *getattro(PyObject *obname);
};
////////////////////////////////////////////////////////
Index: win32ui.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32ui.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** win32ui.h 6 Dec 2008 00:35:20 -0000 1.9
--- win32ui.h 8 Jan 2009 22:11:52 -0000 1.10
***************
*** 135,153 ****
class PYW_EXPORT ui_type : public PyTypeObject {
public:
! ui_type( const char *name, ui_type *pBaseType, int typeSize, struct PyMethodDef* methodList, ui_base_class * (* thector)() );
~ui_type();
public:
- ui_type *base;
struct PyMethodDef* methods;
ui_base_class * (* ctor)();
};
// helper typeCObject class.
class PYW_EXPORT ui_type_CObjec...
[truncated message content] |