Commit 56a4a0d9 authored by Kliment Yanev's avatar Kliment Yanev

Fix escalating memory usage when multiple large files are printed after each other.

React to resend only when the command is in the beginning of a line.
parent aa0a045e
...@@ -114,11 +114,11 @@ class printcore(): ...@@ -114,11 +114,11 @@ class printcore():
pass pass
#callback for errors #callback for errors
pass pass
if "resend" in line.lower() or "rs" in line: if line.lower().startswith("resend") or line.startswith("rs"):
try: try:
toresend=int(line.replace("N:"," ").replace("N"," ").replace(":"," ").split()[-1]) toresend=int(line.replace("N:"," ").replace("N"," ").replace(":"," ").split()[-1])
except: except:
if "rs" in line: if line.startswith("rs"):
toresend=int(line.split()[1]) toresend=int(line.split()[1])
self.resendfrom=toresend self.resendfrom=toresend
self.clear=True self.clear=True
...@@ -195,6 +195,8 @@ class printcore(): ...@@ -195,6 +195,8 @@ class printcore():
pass pass
while(self.printing and self.printer and self.online): while(self.printing and self.printer and self.online):
self._sendnext() self._sendnext()
self.log=[]
self.sent=[]
if self.endcb is not None: if self.endcb is not None:
try: try:
self.endcb() self.endcb()
...@@ -215,6 +217,7 @@ class printcore(): ...@@ -215,6 +217,7 @@ class printcore():
self._send(self.sentlines[self.resendfrom],self.resendfrom,False) self._send(self.sentlines[self.resendfrom],self.resendfrom,False)
self.resendfrom+=1 self.resendfrom+=1
return return
self.sentlines={}
self.resendfrom=-1 self.resendfrom=-1
for i in self.priqueue[:]: for i in self.priqueue[:]:
self._send(i) self._send(i)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment