Skip to content

Commit

Permalink
Don't throw an error when CListCtrl::GetItemText returns an empty str…
Browse files Browse the repository at this point in the history
…ing, as it can do so legitimately

Also, use the CString overload to avoid truncating the output
  • Loading branch information
rupole committed Aug 23, 2012
1 parent 6b90fda commit 475315d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Pythonwin/win32ctrlList.cpp
Expand Up @@ -486,19 +486,18 @@ PyObject *PyCListCtrl_GetItem( PyObject *self, PyObject *args )
PyObject *PyCListCtrl_GetItemText( PyObject *self, PyObject *args )
{
int item, sub;
TCHAR buf[256];
// TCHAR buf[256];
if (!PyArg_ParseTuple( args, "ii:GetItemText",
&item, // @pyparm int|item||The index of the item whose text is to be retrieved.
&sub)) // @pyparm int|sub||Specifies the subitem whose text is to be retrieved.
return NULL;
CListCtrl *pList = GetListCtrl(self);
if (!pList) return NULL;
GUI_BGN_SAVE;
int len = pList->GetItemText(item, sub, buf, sizeof(buf)/sizeof(TCHAR));
// int len = pList->GetItemText(item, sub, buf, sizeof(buf)/sizeof(TCHAR));
CString s = pList->GetItemText(item, sub);
GUI_END_SAVE;
if (len==0)
RETURN_ERR("GetItemText failed");
return PyWinObject_FromTCHAR(buf,len);
return PyWinObject_FromTCHAR(s);
}

// @pymethod int|PyCListCtrl|SetItemText|Changes the text of a list view item or subitem.
Expand Down

0 comments on commit 475315d

Please sign in to comment.