Browse Source

added mutex to logoutput -> no crash ("realloc(): invalid next size") if filters are changed

dev
Clemens Richter 9 years ago
parent
commit
ad49985cf9
  1. 10
      python/tmc_parser.py

10
python/tmc_parser.py

@ -211,7 +211,7 @@ class tmc_parser(gr.sync_block):
else: else:
if self.log or True:#not seen yet -> always print if self.log or True:#not seen yet -> always print
print("alert plus on station %s (%s)"%(PI,psn))#(not seen yet) print("alert plus on station %s (%s)"%(PI,psn))#(not seen yet)
#end of handle_msg
def getqtwidget(self): def getqtwidget(self):
return self.qtwidget return self.qtwidget
def decode_chars(self,charstring): def decode_chars(self,charstring):
@ -256,6 +256,7 @@ class tmc_parser(gr.sync_block):
return return_string return return_string
class tmc_parser_Widget(QtGui.QWidget): class tmc_parser_Widget(QtGui.QWidget):
def print_tmc_msg(self,tmc_msg): def print_tmc_msg(self,tmc_msg):
self.logMutex.acquire(1)
sb=self.logOutput.verticalScrollBar() sb=self.logOutput.verticalScrollBar()
oldmax=sb.maximum() oldmax=sb.maximum()
auto_scroll= abs(oldmax-sb.value())<60#auto_scroll if scrollbar was at max 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() sb=self.logOutput.verticalScrollBar()
new_max=sb.maximum() new_max=sb.maximum()
sb.setValue(new_max) sb.setValue(new_max)
# code.interact(local=locals())
#print("scrolling %i %i %r"%(oldmax,new_max,sb.value())) #print("scrolling %i %i %r"%(oldmax,new_max,sb.value()))
#code.interact(local=locals()) #code.interact(local=locals())
self.logMutex.release(1)
def updateui(self): def updateui(self):
print("updating ui") print("updating ui")
def filterChanged(self): def filterChanged(self):
self.logMutex.acquire(1)
self.parser.isDone=False
ef=unicode(self.event_filter.text().toUtf8(), encoding="UTF-8").lower() ef=unicode(self.event_filter.text().toUtf8(), encoding="UTF-8").lower()
lf=unicode(self.location_filter.text().toUtf8(), encoding="UTF-8").lower() lf=unicode(self.location_filter.text().toUtf8(), encoding="UTF-8").lower()
self.logOutput.clear() self.logOutput.clear()
filters=[{"type":"location", "str":lf},{"type":"event", "str":ef}] filters=[{"type":"location", "str":lf},{"type":"event", "str":ef}]
self.logOutput.append(Qt.QString.fromUtf8(self.parser.tmc_messages.getLogString(filters))) self.logOutput.append(Qt.QString.fromUtf8(self.parser.tmc_messages.getLogString(filters)))
print("filter changed") print("filter changed")
self.logMutex.release(1)
def __init__(self, parser,maxheight): def __init__(self, parser,maxheight):
QtGui.QWidget.__init__(self) QtGui.QWidget.__init__(self)
layout = Qt.QVBoxLayout() layout = Qt.QVBoxLayout()
self.logMutex=QtCore.QSemaphore(1)
self.setLayout(layout) self.setLayout(layout)
self.parser=parser self.parser=parser
self.tmc_message_label=QtGui.QLabel("TMC messages:") self.tmc_message_label=QtGui.QLabel("TMC messages:")
@ -310,4 +317,3 @@ class tmc_parser_Widget(QtGui.QWidget):
font.setFamily("Courier") font.setFamily("Courier")
font.setPointSize(10) font.setPointSize(10)
layout.addWidget(self.logOutput) layout.addWidget(self.logOutput)
self.clip = QtGui.QApplication.clipboard()

Loading…
Cancel
Save