I am new to WX, so I decided to make a program that will periodically write out a line of text to the screen based on an outside input. The basis of the program contains a basic window with the multiline text control covering the entire window. The only other method I have in the frame is to print out what ever the method listen_event
gets as a new line for the multiline TextCtrl. Thats it, as proof the code is below:
class Frame(wx.Frame):def __init__(self):wx.Frame.__init__(self, None,title = 'Program',size = (640, 480),style = wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX)panel = wx.Panel(self)self.textArea = wx.TextCtrl(parent = panel,id = -1,pos = (0, 0),size = (-1, -1),style = wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_AUTO_URL)def listen_event(self, data):self.textArea.AppendText(data)
The listen event is is called periodically from another thread. All seems to be fine, the program works, however, every so often (more often than I would like) I get a massive dump of what reminds me of ObjectiveC error messages:
2013-06-21 20:11:47.820 Python[85638:420b] An uncaught exception was raised
2013-06-21 20:11:47.821 Python[85638:420b] NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds
2013-06-21 20:11:47.824 Python[85638:420b] (0 CoreFoundation 0x00007fff92e2bf56 __exceptionPreprocess + 1981 libobjc.A.dylib 0x00007fff8fc0bd5e objc_exception_throw + 432 CoreFoundation 0x00007fff92e2bd8a +[NSException raise:format:arguments:] + 1063 CoreFoundation 0x00007fff92e2bd14 +[NSException raise:format:] + 1164 Foundation 0x00007fff8fe93b20 -[NSMutableRLEArray replaceObjectsInRange:withObject:length:] + 1325 AppKit 0x00007fff8d3e33f8 -[NSLayoutManager addTemporaryAttribute:value:forCharacterRange:] + 5006 AppKit 0x00007fff8d7f9716 -[NSTextView _markTextEditedForRange:] + 10257 AppKit 0x00007fff8d7f8392 -[NSTextView insertText:replacementRange:] + 24008 AppKit 0x00007fff8d7f7a25 -[NSTextView insertText:] + 3209 libwx_osx_cocoau-2.9.4.0.0.dylib 0x0000000101953b71 _ZN19wxNSTextViewControl9WriteTextERK8wxString + 25710 libwx_osx_cocoau-2.9.4.0.0.dylib 0x00000001018bfb53 _ZN11wxTextEntry9WriteTextERK8wxString + 6711 _core_.so 0x00000001014dec57 _wrap_TextEntryBase_AppendText + 19912 Python 0x00000001000c1112 PyEval_EvalFrameEx + 2262613 Python 0x00000001000c2d29 PyEval_EvalCodeEx + 213714 Python 0x00000001000c0b6a PyEval_EvalFrameEx + 2117815 Python 0x00000001000c1ebe PyEval_EvalFrameEx + 2612616 Python 0x00000001000c1ebe PyEval_EvalFrameEx + 2612617 Python 0x00000001000c1ebe PyEval_EvalFrameEx + 2612618 Python 0x00000001000c1ebe PyEval_EvalFrameEx + 2612619 Python 0x00000001000c2d29 PyEval_EvalCodeEx + 213720 Python 0x00000001000c0b6a PyEval_EvalFrameEx + 2117821 Python 0x00000001000c1ebe PyEval_EvalFrameEx + 2612622 Python 0x00000001000c2d29 PyEval_EvalCodeEx + 213723 Python 0x000000010003da80 function_call + 17624 Python 0x000000010000c5e2 PyObject_Call + 9825 Python 0x000000010001ebcb instancemethod_call + 36326 Python 0x000000010000c5e2 PyObject_Call + 9827 Python 0x00000001000ba5f7 PyEval_CallObjectWithKeywords + 8728 Python 0x0000000100100a63 t_bootstrap + 6729 libsystem_c.dylib 0x00007fff933008bf _pthread_start + 33530 libsystem_c.dylib 0x00007fff93303b75 thread_start + 13
)
2013-06-21 20:11:47.825 Python[85638:420b] *** Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds'
*** First throw call stack:
(0 CoreFoundation 0x00007fff92e2bf56 __exceptionPreprocess + 1981 libobjc.A.dylib 0x00007fff8fc0bd5e objc_exception_throw + 432 CoreFoundation 0x00007fff92e2bd8a +[NSException raise:format:arguments:] + 1063 CoreFoundation 0x00007fff92e2bd14 +[NSException raise:format:] + 1164 Foundation 0x00007fff8fe93b20 -[NSMutableRLEArray replaceObjectsInRange:withObject:length:] + 1325 AppKit 0x00007fff8d3e33f8 -[NSLayoutManager addTemporaryAttribute:value:forCharacterRange:] + 5006 AppKit 0x00007fff8d7f9716 -[NSTextView _markTextEditedForRange:] + 10257 AppKit 0x00007fff8d7f8392 -[NSTextView insertText:replacementRange:] + 24008 AppKit 0x00007fff8d7f7a25 -[NSTextView insertText:] + 3209 libwx_osx_cocoau-2.9.4.0.0.dylib 0x0000000101953b71 _ZN19wxNSTextViewControl9WriteTextERK8wxString + 25710 libwx_osx_cocoau-2.9.4.0.0.dylib 0x00000001018bfb53 _ZN11wxTextEntry9WriteTextERK8wxString + 6711 _core_.so 0x00000001014dec57 _wrap_TextEntryBase_AppendText + 19912 Python 0x00000001000c1112 PyEval_EvalFrameEx + 2262613 Python 0x00000001000c2d29 PyEval_EvalCodeEx + 213714 Python 0x00000001000c0b6a PyEval_EvalFrameEx + 2117815 Python 0x00000001000c1ebe PyEval_EvalFrameEx + 2612616 Python 0x00000001000c1ebe PyEval_EvalFrameEx + 2612617 Python 0x00000001000c1ebe PyEval_EvalFrameEx + 2612618 Python 0x00000001000c1ebe PyEval_EvalFrameEx + 2612619 Python 0x00000001000c2d29 PyEval_EvalCodeEx + 213720 Python 0x00000001000c0b6a PyEval_EvalFrameEx + 2117821 Python 0x00000001000c1ebe PyEval_EvalFrameEx + 2612622 Python 0x00000001000c2d29 PyEval_EvalCodeEx + 213723 Python 0x000000010003da80 function_call + 17624 Python 0x000000010000c5e2 PyObject_Call + 9825 Python 0x000000010001ebcb instancemethod_call + 36326 Python 0x000000010000c5e2 PyObject_Call + 9827 Python 0x00000001000ba5f7 PyEval_CallObjectWithKeywords + 8728 Python 0x0000000100100a63 t_bootstrap + 6729 libsystem_c.dylib 0x00007fff933008bf _pthread_start + 33530 libsystem_c.dylib 0x00007fff93303b75 thread_start + 13
)
terminate called throwing an exception
What gives? I cannot find a rhyme or reason for these errors. On occasion it works for a couple in a row, then crashes. And sometimes it crashes on the first go. Am I implementing the text control box incorrectly?