From ad49985cf99633602ea20e4693258bd43a0f5ff1 Mon Sep 17 00:00:00 2001 From: csrichter Date: Fri, 28 Apr 2017 14:25:01 +0200 Subject: [PATCH] added mutex to logoutput -> no crash ("realloc(): invalid next size") if filters are changed --- python/tmc_parser.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/python/tmc_parser.py b/python/tmc_parser.py index e157ab8..bc8a27a 100644 --- a/python/tmc_parser.py +++ b/python/tmc_parser.py @@ -211,7 +211,7 @@ class tmc_parser(gr.sync_block): else: if self.log or True:#not seen yet -> always print print("alert plus on station %s (%s)"%(PI,psn))#(not seen yet) - + #end of handle_msg def getqtwidget(self): return self.qtwidget def decode_chars(self,charstring): @@ -256,6 +256,7 @@ class tmc_parser(gr.sync_block): return return_string class tmc_parser_Widget(QtGui.QWidget): def print_tmc_msg(self,tmc_msg): + self.logMutex.acquire(1) sb=self.logOutput.verticalScrollBar() oldmax=sb.maximum() auto_scroll= abs(oldmax-sb.value())<60#auto_scroll if scrollbar was at max @@ -271,20 +272,26 @@ class tmc_parser_Widget(QtGui.QWidget): sb=self.logOutput.verticalScrollBar() new_max=sb.maximum() sb.setValue(new_max) + # code.interact(local=locals()) #print("scrolling %i %i %r"%(oldmax,new_max,sb.value())) #code.interact(local=locals()) + self.logMutex.release(1) def updateui(self): print("updating ui") def filterChanged(self): + self.logMutex.acquire(1) + self.parser.isDone=False ef=unicode(self.event_filter.text().toUtf8(), encoding="UTF-8").lower() lf=unicode(self.location_filter.text().toUtf8(), encoding="UTF-8").lower() self.logOutput.clear() filters=[{"type":"location", "str":lf},{"type":"event", "str":ef}] self.logOutput.append(Qt.QString.fromUtf8(self.parser.tmc_messages.getLogString(filters))) print("filter changed") + self.logMutex.release(1) def __init__(self, parser,maxheight): QtGui.QWidget.__init__(self) layout = Qt.QVBoxLayout() + self.logMutex=QtCore.QSemaphore(1) self.setLayout(layout) self.parser=parser self.tmc_message_label=QtGui.QLabel("TMC messages:") @@ -310,4 +317,3 @@ class tmc_parser_Widget(QtGui.QWidget): font.setFamily("Courier") font.setPointSize(10) layout.addWidget(self.logOutput) - self.clip = QtGui.QApplication.clipboard()