Update of /cvsroot/pywin32/pywin32/Pythonwin
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv4422/Pythonwin
Modified Files:
Tag: py3k
win32cmdui.cpp win32notify.cpp win32oleDlgInsert.cpp
win32template.cpp win32toolbar.cpp win32toolbar.h
win32uiole.cpp win32util.cpp
Log Message:
Re-integrate various fixes etc implemented during trunk merge.
Index: win32oleDlgInsert.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32oleDlgInsert.cpp,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -C2 -d -r1.1.4.1 -r1.1.4.2
*** win32oleDlgInsert.cpp 29 Aug 2008 05:53:29 -0000 1.1.4.1
--- win32oleDlgInsert.cpp 13 Nov 2008 05:02:23 -0000 1.1.4.2
***************
*** 7,10 ****
--- 7,11 ----
// @doc
+ // XXX - is this actually used?????????
class OLEUIINSERTOBJECTHelper
{
***************
*** 30,33 ****
--- 31,38 ----
OLEUIINSERTOBJECTHelper::~OLEUIINSERTOBJECTHelper()
{
+ if (pConv->lpszCaption)
+ PyWinObject_FreeTCHAR((TCHAR *)pConv->lpszCaption);
+ if (pConv->lpszTemplate)
+ PyWinObject_FreeTCHAR((TCHAR *)pConv->lpszTemplate);
}
***************
*** 63,68 ****
ob = PyObject_GetAttrString(obDict, "Caption");
if (ob){
! // ??? This needs to be freed somewhere ???
! // Need cast since lpszCaption is const
if (!PyWinObject_AsTCHAR(ob, (TCHAR **)&pConv->lpszCaption, FALSE))
return FALSE;
--- 68,72 ----
ob = PyObject_GetAttrString(obDict, "Caption");
if (ob){
! // Need cast since lpszCaption is const. Free'd in object dtor
if (!PyWinObject_AsTCHAR(ob, (TCHAR **)&pConv->lpszCaption, FALSE))
return FALSE;
***************
*** 83,87 ****
ob = PyObject_GetAttrString(obDict, "Template");
if (ob){
! // ??? This needs to be freed somewhere ???
if (!PyWinObject_AsTCHAR(ob, (TCHAR **)&pConv->lpszTemplate, FALSE))
return FALSE;
--- 87,91 ----
ob = PyObject_GetAttrString(obDict, "Template");
if (ob){
! // Need cast since lpszTemplate is const. Free'd in object dtor
if (!PyWinObject_AsTCHAR(ob, (TCHAR **)&pConv->lpszTemplate, FALSE))
return FALSE;
Index: win32notify.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32notify.cpp,v
retrieving revision 1.7.2.2
retrieving revision 1.7.2.3
diff -C2 -d -r1.7.2.2 -r1.7.2.3
*** win32notify.cpp 2 Sep 2008 02:14:43 -0000 1.7.2.2
--- win32notify.cpp 13 Nov 2008 05:02:23 -0000 1.7.2.3
***************
*** 130,134 ****
{
char *pUse = (char *)(ptr+1);
! BOOL bIgnore;
int argNum = 0;
if (fmt==NULL){
--- 130,135 ----
{
char *pUse = (char *)(ptr+1);
! BOOL bIgnoreFormat;
! BOOL bIgnoreValue;
int argNum = 0;
if (fmt==NULL){
***************
*** 140,144 ****
PyObject *ob = PyTuple_GetItem(args, argNum);
if (ob==NULL) return;
! bIgnore = *fmt=='-';
if (bIgnore) ++fmt;
switch (*fmt) {
--- 141,148 ----
PyObject *ob = PyTuple_GetItem(args, argNum);
if (ob==NULL) return;
! bIgnoreFormat = *fmt=='-';
! // The user can specify 'None' to say 'leave the value alone'
! bIgnoreValue = (ob == Py_None);
! BOOL bIgnore = bIgnoreFormat || bIgnoreValue;
if (bIgnore) ++fmt;
switch (*fmt) {
***************
*** 158,161 ****
--- 162,173 ----
break;
}
+ case 'V':{// Pointer-sized number, also used for HANDLEs, LPARAMS, etc
+ if (!bIgnore) {
+ if (!PyWinLong_AsVoidPtr(ob, (void **)pUse))
+ return;
+ }
+ pUse += (sizeof(void *));
+ break;
+ }
case 'z': // string pointer
if (!bIgnore) {
***************
*** 217,221 ****
}
fmt++;
! if (!bIgnore)
argNum ++;
}
--- 229,233 ----
}
fmt++;
! if (!bIgnoreFormat)
argNum ++;
}
***************
*** 291,300 ****
else if (code == TCN_KEYDOWN)
fmt = "ii"; // NMTCKEYDOWN - ??? First element is a WORD, may work due to alignment ???
else if (code == TTN_NEEDTEXTW)
! fmt = "-ZS80ii"; //TOOLTIPTEXT
else if (code == TTN_POP || code == TTN_SHOW)
fmt = NULL; //NMHDR only
- else if (code == TTN_NEEDTEXTA)
- fmt = "-zs80Vi"; // NMTTDISPINFO - Third element is HINSTANCE
else if (code == TVN_ENDLABELEDITW || code == TVN_BEGINLABELEDITW || code == TVN_SETDISPINFOW
|| code == TVN_GETDISPINFOW || code == TVN_ENDLABELEDITA || code == TVN_BEGINLABELEDITA
--- 303,312 ----
else if (code == TCN_KEYDOWN)
fmt = "ii"; // NMTCKEYDOWN - ??? First element is a WORD, may work due to alignment ???
+ else if (code == TTN_NEEDTEXTA)
+ fmt = "-zs80Vi"; // TOOLTIPTEXTA - ie, NMTTDISPINFOA
else if (code == TTN_NEEDTEXTW)
! fmt = "-ZS80Vi"; // TOOLTIPTEXTW - ie, NMTTDISPINFOW
else if (code == TTN_POP || code == TTN_SHOW)
fmt = NULL; //NMHDR only
else if (code == TVN_ENDLABELEDITW || code == TVN_BEGINLABELEDITW || code == TVN_SETDISPINFOW
|| code == TVN_GETDISPINFOW || code == TVN_ENDLABELEDITA || code == TVN_BEGINLABELEDITA
***************
*** 351,358 ****
PyObject *obOther;
PyObject *result = Python_do_callback(method, args);
! if (result==NULL) {
PyErr_Warn(PyExc_Warning, "Exception in OnNotify() handler");
- gui_print_error();
- }
else if (result==Py_None) // allow for None "dont pass on", else result to windows
bPassOn = TRUE;
--- 363,368 ----
PyObject *obOther;
PyObject *result = Python_do_callback(method, args);
! if (result==NULL)
PyErr_Warn(PyExc_Warning, "Exception in OnNotify() handler");
else if (result==Py_None) // allow for None "dont pass on", else result to windows
bPassOn = TRUE;
Index: win32cmdui.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32cmdui.cpp,v
retrieving revision 1.6.4.1
retrieving revision 1.6.4.2
diff -C2 -d -r1.6.4.1 -r1.6.4.2
*** win32cmdui.cpp 29 Aug 2008 05:53:29 -0000 1.6.4.1
--- win32cmdui.cpp 13 Nov 2008 05:02:23 -0000 1.6.4.2
***************
*** 113,116 ****
--- 113,119 ----
Python_callback (method, ob);
if (PyErr_Occurred()) // if any Python exception, pretend it was OK
+ // XXX - Python_callback always calls
+ // gui_print_error() on failure, which
+ // clears the error - so we can't get here?
gui_print_error();
// object is no longer valid.
***************
*** 139,144 ****
CEnterLeavePython _celp;
rc = Python_callback (method, nID, nCode);
! if (rc==-1 && PyErr_Occurred()) { // if any Python exception, print it
! gui_print_error();
char buf[128];
sprintf(buf, "Error in Command Message handler for command ID %u, Code %d", nID, nCode);
--- 142,150 ----
CEnterLeavePython _celp;
rc = Python_callback (method, nID, nCode);
! // This is dodgy - we have to rely on -1 and can't check PyErr_Occurred(),
! // as Python_callback will have called gui_print_error() which clears
! // the error.
! if (rc==-1) {
! // Raise a *new* exception then print that too.
char buf[128];
sprintf(buf, "Error in Command Message handler for command ID %u, Code %d", nID, nCode);
Index: win32template.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32template.cpp,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -C2 -d -r1.4.2.1 -r1.4.2.2
*** win32template.cpp 29 Aug 2008 05:53:29 -0000 1.4.2.1
--- win32template.cpp 13 Nov 2008 05:02:23 -0000 1.4.2.2
***************
*** 109,112 ****
--- 109,113 ----
{
TCHAR *fileName = NULL; // default, untitled document
+ PyObject *ret = NULL;
PyObject *obfileName=Py_None;
if (!PyArg_ParseTuple(args,"|O", &obfileName))
***************
*** 114,121 ****
if (!PyWinObject_AsTCHAR(obfileName, &fileName, TRUE))
return NULL;
CDocument *pDoc = NULL;
if (fileName) {
CProtectedWinApp *pApp = GetProtectedApp();
! if (!pApp) return NULL;
// need to look for an open doc of same name, and return that object.
// Let MFC framework search for a filename for us.
--- 115,123 ----
if (!PyWinObject_AsTCHAR(obfileName, &fileName, TRUE))
return NULL;
+ // must exit via 'done' from here...
CDocument *pDoc = NULL;
if (fileName) {
CProtectedWinApp *pApp = GetProtectedApp();
! if (!pApp) goto done;
// need to look for an open doc of same name, and return that object.
// Let MFC framework search for a filename for us.
***************
*** 126,138 ****
CPythonDocTemplate *pMFCTemplate = GetTemplate(self);
if (pMFCTemplate==NULL)
! return NULL;
CObject *pOb;
GUI_BGN_SAVE;
pOb = pClass->CreateObject();
GUI_END_SAVE;
! if (pOb==NULL)
! RETURN_MEM_ERR("error creating document object");
! if (!pOb->IsKindOf( RUNTIME_CLASS(CDocument)))
! RETURN_ERR("Internal error: Unknown created instead of a document");
pDoc = (CDocument *)pOb;
pMFCTemplate->AddDocument(pDoc);
--- 128,144 ----
CPythonDocTemplate *pMFCTemplate = GetTemplate(self);
if (pMFCTemplate==NULL)
! goto done;
CObject *pOb;
GUI_BGN_SAVE;
pOb = pClass->CreateObject();
GUI_END_SAVE;
! if (pOb==NULL) {
! PyErr_NoMemory();
! goto done;
! }
! if (!pOb->IsKindOf( RUNTIME_CLASS(CDocument))) {
! PyErr_SetString(ui_module_error, "Internal error: Unknown created instead of a document");
! goto done;
! }
pDoc = (CDocument *)pOb;
pMFCTemplate->AddDocument(pDoc);
***************
*** 147,153 ****
// }
}
! // ??? Some of the error returns above need to free this also ???
PyWinObject_FreeTCHAR(fileName);
! return ui_assoc_object::make(pydoc_type, pDoc);
}
--- 153,160 ----
// }
}
! ret = ui_assoc_object::make(pydoc_type, pDoc);
! done:
PyWinObject_FreeTCHAR(fileName);
! return ret;
}
Index: win32toolbar.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32toolbar.h,v
retrieving revision 1.2.4.1
retrieving revision 1.2.4.2
diff -C2 -d -r1.2.4.1 -r1.2.4.2
*** win32toolbar.h 29 Aug 2008 05:53:29 -0000 1.2.4.1
--- win32toolbar.h 13 Nov 2008 05:02:23 -0000 1.2.4.2
***************
*** 40,43 ****
--- 40,45 ----
static ui_type_CObject type;
CPtrArray *bmplist;
+ // Array of pointers, each holding the result of one call to
+ // PyWinObject_AsMultipleString()
CPtrArray *strlist;
protected:
Index: win32util.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32util.cpp,v
retrieving revision 1.13.2.3
retrieving revision 1.13.2.4
diff -C2 -d -r1.13.2.3 -r1.13.2.4
*** win32util.cpp 4 Sep 2008 02:27:19 -0000 1.13.2.3
--- win32util.cpp 13 Nov 2008 05:02:23 -0000 1.13.2.4
***************
*** 775,778 ****
--- 775,781 ----
}
+ /**** NOT USED: No current callers of this - and when there are, we need to
+ * ensure we PyWinObject_FreeTCHAR() pItem->pszText - see '????' below
+ *
// *** When PyCHeaderCtrl is implemented, return the '@' to the next line _and_ the parm!
// pymethod |PyCHeaderCtrl|HD_ITEM tuple|Describes a HD_ITEM tuple, used by the <o PyCHeaderCtrl> object.
***************
*** 853,857 ****
return !PyErr_Occurred();
}
!
/////////////////////////////////////////////////////////////////////
--- 856,860 ----
return !PyErr_Occurred();
}
! *******************************************/
/////////////////////////////////////////////////////////////////////
Index: win32toolbar.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32toolbar.cpp,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -C2 -d -r1.3.2.1 -r1.3.2.2
*** win32toolbar.cpp 29 Aug 2008 05:53:29 -0000 1.3.2.1
--- win32toolbar.cpp 13 Nov 2008 05:02:23 -0000 1.3.2.2
***************
*** 934,938 ****
n = strlist->GetSize();
for (i = 0; i < n; i++)
! delete strlist->GetAt (i);
delete strlist;
}
--- 934,938 ----
n = strlist->GetSize();
for (i = 0; i < n; i++)
! PyWinObject_FreeMultipleString((TCHAR *)strlist->GetAt(i));
delete strlist;
}
***************
*** 1038,1057 ****
return NULL;
! // ??? Need to change destructor to call FreeMultipleString ???
! ((PyCToolBarCtrl *) self)->strlist->Add (strings);
// @pyparm string...|strings||Strings to add. Can give more than one string.
-
- /*
- * Okay, so this is REALLY ugly... Blame Microsoft in this case.
- * They actually require that you pass in a bunch of strings,
- * separated by NULL bytes, and terminated by TWO NULL bytes.
- * I'm going to go wash my hands now...
- */
-
GUI_BGN_SAVE;
! int rc = pTBC->AddStrings (strings);
GUI_END_SAVE;
-
return PyInt_FromLong(rc);
}
--- 1038,1050 ----
return NULL;
! // Add string pointer to list of things to be cleaned up at the end.
! // (XXX - is this really necessary? It seems surprising the control
! // doesn't take its own copy???)
! ((PyCToolBarCtrl *) self)->strlist->Add(strings);
// @pyparm string...|strings||Strings to add. Can give more than one string.
GUI_BGN_SAVE;
! int rc = pTBC->AddStrings(strings);
GUI_END_SAVE;
return PyInt_FromLong(rc);
}
Index: win32uiole.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uiole.cpp,v
retrieving revision 1.8.2.1
retrieving revision 1.8.2.2
diff -C2 -d -r1.8.2.1 -r1.8.2.2
*** win32uiole.cpp 29 Aug 2008 05:53:30 -0000 1.8.2.1
--- win32uiole.cpp 13 Nov 2008 05:02:23 -0000 1.8.2.2
***************
*** 169,178 ****
};
! #define ADD_CONSTANT(tok) if (rc=PyModule_AddIntConstant(module, #tok, tok)) return rc
! #define ADD_ENUM(parta, partb) if (rc=PyModule_AddIntConstant(module, #parta "_" #partb, parta::partb)) return rc
int AddConstants(PyObject *module)
{
- int rc;
ADD_ENUM(COleClientItem, emptyState);// @const win32uiole|COleClientItem_emptyState|
ADD_ENUM(COleClientItem, loadedState);// @const win32uiole|COleClientItem_loadedState|
--- 169,177 ----
};
! #define ADD_CONSTANT(tok) if (PyModule_AddIntConstant(module, #tok, tok)==-1) return -1
! #define ADD_ENUM(parta, partb) if (PyModule_AddIntConstant(module, #parta "_" #partb, parta::partb)==-1) return -1
int AddConstants(PyObject *module)
{
ADD_ENUM(COleClientItem, emptyState);// @const win32uiole|COleClientItem_emptyState|
ADD_ENUM(COleClientItem, loadedState);// @const win32uiole|COleClientItem_loadedState|
|