wx.PyTextDataObject with drag and drop results in extra characters

给你一囗甜甜゛ 提交于 2019-12-13 02:22:34

问题


I'm using wx.PyTextDataObject as the data object for a drag and drop setup in wxPython. When the user selects an item to drag the text is copied into a wx.PyTextDataObject and on drop the PyTextDataObject is copied into another (this is internal to wx, I don't control this). The problem i'm having is that occasionally the copied text will contain a bit of garbage on the end. It looks like some kind of buffer overflow problem in wx.

I've narrowed the problem down to the following example. The string in the example is from a use case that we've had problems with, drop one letter and there is no problem.

>>> import wx
>>> src = wx.PyTextDataObject(u'HR7984,HR8488,HR8893,HC7984,HC8488,HC8893,PO7984,PO8488,PO8893')
>>> dst = wx.PyTextDataObject()
>>> dst.SetData(src.GetDataHere())
True
>>> dst.GetText()
u'HR7984,HR8488,HR8893,HC7984,HC8488,HC8893,PO7984,PO8488,PO8893\u1f00x'
>>> src.GetText()
u'HR7984,HR8488,HR8893,HC7984,HC8488,HC8893,PO7984,PO8488,PO8893'
>>> 

Has anyone experienced this bug before? Any ideas where the problem might be? If it's in wxWidgets I'd like to find a patch.

My setup is OSX, python 2.7, wx 2.8.12.1 (mac-unicode) Carbon.

来源:https://stackoverflow.com/questions/8423197/wx-pytextdataobject-with-drag-and-drop-results-in-extra-characters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!