Bug 461 : while()-loop freezes processing (again)
Last modified: 2006-11-28 13:06




Status:
RESOLVED
Resolution:
DUPLICATE of bug 460
Priority:
P2
Severity:
normal

 

Reporter:
markus
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2006-11-28 13:00
okay, you missunderstood me so i post again, this time with runnable code:

---------------8<---------

public class test extends PApplet
{

void setup()
{
size(100,100);
}

void draw()
{
fill(45);
rect(0,0,50,50);
while(!keyPressed) { }
}

}

-----------------8<-------------

run the program, it will hang BEFORE the rectangle is drawed to screen.
(on windowsmachines, works properly on unixmachines as i said.)
Additional Comment #1 From fry 2006-11-28 13:06
i understand just fine. the screen won't update until the draw() method
finishes, and keyPressed is only updated once during draw(). and by placing
things in such a tight loop, no time is given to the operating system to
allow key or mouse events to come through anyway.

you'll notice we never use while() in such a manner in any of the examples,
in fact i'm not sure if we use while() at all since it's so prone to
confusions such as these.

*** This bug has been marked as a duplicate of 460 ***