Bug 213 : Having a method called "display" in your sketch will cause problems.
Last modified: 2006-03-23 09:29




Status:
RESOLVED
Resolution:
FIXED -
Priority:
P2
Severity:
normal

 

Reporter:
timdiggins
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2005-11-15 13:10
If you have a method called "display" in a sketch then there will be a
failure to launch the applet window.

If you're lucky, then this will show an error (because it will get to some
draw() code which will throw an error, because setup was never called).

If you're really unlucky then processing locks up and not display the
running sketch (because locked in a loop of displaying draw() with no
sketch?).

This is happening (I'm pretty sure) because the sketch's method is
overriding method display() in PApplet. Could that be made private or final
to stop this (at least final would generate an error). Or can the pde
compiler mangle the name display (which is a common enough method name)...

this happened to me (took some time to figure it out).

example:

class MyColour {
int colour;

MyColour(int colour){
this.colour = colour;
}
int getColour(){
return colour;
}
}

MyColour mycolour;

void setup(){
mycolour = new MyColour(0x80);
}

void draw(){
int col = mycolour.getColour();
background(col);
}
void display(){
print(mycolour.getColour());
// or replace with
// print("d");
// for more fun;
}
Additional Comment #1 From fry 2005-11-16 08:20
k, prolly needs to be renamed since it's too generic for this type of work,
but in the process we should prolly make it final too.. or better, start
using some sort of internal api naming convention (hrm), since the errors
from making it final would prolly be totally obscure.
Additional Comment #2 From fry 2006-03-23 09:29
k, changed name to handleDisplay() for 0111 which shouldn't cause as much
trouble.