mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-08 21:10:06 +01:00
Merge pull request #470 from RobinD42/fix-issue467
Fix wx.ListCtrl.SetItemData
This commit is contained in:
@@ -36,6 +36,8 @@ Changes in this release include the following:
|
||||
* Fixes to ensure that the locale message catalogs are included in the
|
||||
release files. (#464)
|
||||
|
||||
* Fix wx.ListCtrl.SetItemData to check that the data value is not out of
|
||||
the range of a C long. (#467)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -98,8 +98,30 @@ def run():
|
||||
(wxIntPtr)fnSortCallBack);
|
||||
""")
|
||||
|
||||
# SetItemData takes a long, so lets return that type from GetItemData too,
|
||||
# instead of a wxUIntPtr.
|
||||
c.find('GetItemData').type = 'long'
|
||||
c.find('SetItemPtrData').ignore()
|
||||
|
||||
# Monkey-patch SetItemData to ensure the data value isn't too big. It's
|
||||
# limited to a C long...
|
||||
orig = c.find('SetItemData')
|
||||
orig.pyName = '_SetItemData'
|
||||
orig.docsignored = True
|
||||
|
||||
c.addPyMethod('SetItemData', '(self, item, data)',
|
||||
doc="Associates an application-defined data value with this item.",
|
||||
body="""\
|
||||
from wx._core import _LONG_MIN, _LONG_MAX
|
||||
if data < _LONG_MIN or data > _LONG_MAX:
|
||||
raise OverflowError("Values limited to what can be held in a C long.")
|
||||
return self._SetItemData(item, data)
|
||||
""")
|
||||
|
||||
|
||||
|
||||
# Change the semantics of GetColumn to return the item as the return
|
||||
# value instead of through a prameter.
|
||||
# value instead of through a parameter.
|
||||
# bool GetColumn(int col, wxListItem& item) const;
|
||||
c.find('GetColumn').ignore()
|
||||
c.addCppMethod('wxListItem*', 'GetColumn', '(int col)',
|
||||
|
||||
@@ -138,6 +138,16 @@ void wxPyCoreModuleInject(PyObject* moduleDict)
|
||||
|
||||
PyDict_SetItemString(moduleDict, "wxWidgets_version", wx2PyString(wxVERSION_STRING));
|
||||
|
||||
PyDict_SetItemString(moduleDict, "_sizeof_int", PyLong_FromLong(sizeof(int)));
|
||||
PyDict_SetItemString(moduleDict, "_sizeof_long", PyLong_FromLong(sizeof(long)));
|
||||
PyDict_SetItemString(moduleDict, "_sizeof_longlong", PyLong_FromLong(sizeof(long long)));
|
||||
PyDict_SetItemString(moduleDict, "_sizeof_double", PyLong_FromLong(sizeof(double)));
|
||||
PyDict_SetItemString(moduleDict, "_sizeof_size_t", PyLong_FromLong(sizeof(size_t)));
|
||||
PyDict_SetItemString(moduleDict, "_LONG_MIN", PyLong_FromLong(LONG_MIN));
|
||||
PyDict_SetItemString(moduleDict, "_LONG_MAX", PyLong_FromLong(LONG_MAX));
|
||||
PyDict_SetItemString(moduleDict, "_LLONG_MIN", PyLong_FromLongLong(PY_LLONG_MIN));
|
||||
PyDict_SetItemString(moduleDict, "_LLONG_MAX", PyLong_FromLongLong(PY_LLONG_MAX));
|
||||
|
||||
// Make a tuple of strings that gives more info about the platform and build.
|
||||
PyObject* PlatformInfo = PyList_New(0);
|
||||
PyObject* obj;
|
||||
|
||||
@@ -172,8 +172,27 @@ class listctrl_Tests(wtc.WidgetTestCase):
|
||||
wx.LIST_FIND_RIGHT
|
||||
|
||||
|
||||
def _makeListCtrl(self):
|
||||
lc = wx.ListCtrl(self.frame, style=wx.LC_REPORT)
|
||||
lc.AppendColumn('AAAA')
|
||||
lc.AppendColumn('BBBB')
|
||||
lc.InsertItem(0, 'item 1A')
|
||||
lc.SetItem(0, 1, 'item 1B')
|
||||
return lc
|
||||
|
||||
|
||||
def test_listctrlItemData01(self):
|
||||
lc = self._makeListCtrl()
|
||||
lc.SetItemData(0, 12345)
|
||||
data = lc.GetItemData(0)
|
||||
assert data == 12345
|
||||
|
||||
|
||||
def test_listctrlItemData02(self):
|
||||
lc = self._makeListCtrl()
|
||||
with self.assertRaises(OverflowError):
|
||||
lc.SetItemData(0, wx._core._LONG_MAX + 100)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user