wx.PyTextDataObject 拖放会产生额外的字符
我使用 wx.PyTextDataObject 作为 wxPython 中拖放设置的数据对象。当用户选择要拖动的项目时,文本将被复制到 wx.PyTextDataObject 中,并且在拖放时,PyTextDataObject 会被复制到另一个项目中(这是 wx 内部的,我不控制它)。我遇到的问题是,有时复制的文本末尾会包含一些垃圾。看起来像是 wx 中的某种缓冲区溢出问题。
我已将问题范围缩小到以下示例。示例中的字符串来自我们遇到问题的一个用例,删除一个字母就没有问题。
>>> 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'
>>>
以前有人遇到过这个错误吗?有什么想法可能是问题出在哪里吗?如果它在 wxWidgets 中,我想找到一个补丁。
我的设置是 OSX、python 2.7、wx 2.8.12.1 (mac-unicode) Carbon。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论