1
0
Fork 0

Update by Anders Gidenstein to prevent scripts producing the error:

"WARNING: PUI: Too many live puInterfaces open at once!"
due to multiple window/dialog updates during the same frame.
This error has been reported to cause FG to crash, but this cannot be
reliably reproduced.
This commit is contained in:
vmmeazza 2010-02-12 23:35:22 +00:00
parent bbaeb45aea
commit 50adc28ff7

View file

@ -88,6 +88,8 @@ var window = {
m.skiptimer = 0;
m.dialog = nil;
m.namenode = props.Node.new({ "dialog-name": m.name });
m.writebuffer = [];
m.MAX_BUFFER_SIZE = 50;
setlistener("/sim/startup/xsize", func m._redraw_());
setlistener("/sim/startup/ysize", func m._redraw_());
return m;
@ -95,6 +97,8 @@ var window = {
write : func(msg, r = nil, g = nil, b = nil, a = nil) {
if (me.namenode == nil)
return;
if (size(me.writebuffer) > me.MAX_BUFFER_SIZE)
return;
if (r == nil)
r = me.fg[0];
if (g == nil)
@ -103,18 +107,14 @@ var window = {
b = me.fg[2];
if (a == nil)
a = me.fg[3];
var lines = [];
foreach (var line; split("\n", string.trim(msg ~ ""))) {
line = sanitize(string.trim(line));
append(me.lines, [line, r, g, b, a]);
if (size(me.lines) > me.maxlines) {
me.lines = subvec(me.lines, 1);
if (me.autoscroll)
me.skiptimer += 1;
}
if (me.autoscroll)
settimer(func me._timeout_(), me.autoscroll, 1);
append(lines, [line, r, g, b, a]);
}
me.show();
if (size(me.writebuffer) == 0)
settimer(func { me._write_(); } , 0, 1);
append(me.writebuffer, lines);
},
show : func {
if (me.dialog != nil)
@ -152,6 +152,25 @@ var window = {
me.y = me.dialog.prop().getNode("lasty").getValue();
}
},
_write_ : func() {
if (size(me.writebuffer) == 0)
return;
var lines = me.writebuffer[0];
me.writebuffer = subvec(me.writebuffer, 1);
foreach (var line; lines) {
append(me.lines, line);
if (size(me.lines) > me.maxlines) {
me.lines = subvec(me.lines, 1);
if (me.autoscroll)
me.skiptimer += 1;
}
if (me.autoscroll)
settimer(func me._timeout_(), me.autoscroll, 1);
}
if (size(me.writebuffer) > 0)
settimer(func { me._write_(); } , 0, 1);
me.show();
},
_timeout_ : func {
if (me.skiptimer > 0) {
me.skiptimer -= 1;