ported from master branch

fixed mem leak with adding external qt event processing

Conflicts:
	ekgplotter/ekgplotter/main.py
This commit is contained in:
Stefan Kögl 2014-03-26 14:25:24 +01:00
parent 41e512c9ef
commit e889b3a88c
1 changed files with 7 additions and 10 deletions

View File

@ -68,8 +68,6 @@ except ImportError as e:
from chaosc.osc_lib import decode_osc
class OSCThread(threading.Thread):
def __init__(self, args):
super(OSCThread, self).__init__()
@ -271,7 +269,7 @@ class EkgPlot(object):
def update(self, osc_address, value):
print("update"), osc_address
res = self.ekg_regex.match(osc_address)
if res:
#print("matched data")
@ -295,7 +293,6 @@ class EkgPlot(object):
if res:
actor_name = res.group(1)
actor_obj = self.actors[actor_name]
#print("matched ctl", value, actor_name, actor_obj.active)
if value == 1 and not actor_obj.active:
#print("actor on", actor_name, actor_obj, self.active_actors)
actor_obj.active = True
@ -303,16 +300,14 @@ class EkgPlot(object):
self.plot.addItem(actor_obj.plotItem)
self.plot.addItem(actor_obj.plotPoint)
self.active_actors.append(actor_obj)
assert actor_obj in self.active_actors
elif value == 0 and actor_obj.active:
#print("actor off", actor_name, actor_obj, self.active_actors)
#print "actor off", actor_name
actor_obj.active = False
self.plot.removeItem(actor_obj.plotItem)
self.plot.removeItem(actor_obj.plotPoint)
try:
self.active_actors.remove(actor_obj)
except ValueError as e:
#print("ctl", e)
pass
assert actor_obj not in self.active_actors
@ -346,14 +341,18 @@ class MyHandler(BaseHTTPRequestHandler):
actor_names = [b"bjoern", b"merle", b"uwe"]
num_data = 100
colors = ["r", "g", "b"]
self.plotter = plotter = EkgPlot(actor_names, num_data, colors)
qtapp = QtGui.QApplication([])
self.plotter = plotter = EkgPlot(actor_names, num_data, colors)
self.send_header("Content-Type", "multipart/x-mixed-replace; boundary=--aaboundary\r\n\r\n")
self.end_headers()
#lastTime = time.time()
#fps = None
event_loop = QtCore.QEventLoop()
while 1:
event_loop.processEvents()
qtapp.sendPostedEvents(None, 0)
while 1:
try:
osc_address, args = msg_queue.get_nowait()
@ -440,8 +439,6 @@ def main():
add_subscriber_group(arg_parser, "ekgplotter")
args = finalize_arg_parser(arg_parser)
qtapp = QtGui.QApplication([])
http_host, http_port = resolve_host(args.http_host, args.http_port, args.address_family)
server = JustAHTTPServer((http_host, http_port), MyHandler)