Bug 1446 : overwritten main([]) cannot be used from within the pde
Last modified: 2010-02-05 14:01




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

 

Reporter:
hansi
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2010-01-26 06:03
Example code:

[code]
static public void main(String args[]) {
println( "in main" );
PApplet.main(new String[] { "<sketch_name>" } );
}


void setup(){
println( "in setup" );
}
[/code]


When run from the PDE this outputs just
"in setup"

When run as an exported application it results in
"in main"
"in setup"


Be it a bug or a feature request, I think it is a bit incosistent.
The problem seems to be in Runner.java#getSketchParams():
[code]
[...]
params.add("processing.core.PApplet");
[...]
params.add(appletClassName);
[/code]

If the occurence of "processing.core.PApplet" was replaced by appletClassName it should work.
Additional Comment #1 From hansi 2010-01-26 06:04
p.s. priority superlow... just came across it and thought it might be interresting.
Additional Comment #2 From fry 2010-01-28 14:01
Interesting, this is a leftover from when sketches were run in the same
process (pre-1.0) so that they'd be faster. But now that we're launching
out to other code, we may as well handle the main() in the same fashion.
Might actually reduce some code to fix it.
Additional Comment #3 From fry 2010-02-05 14:01
k, the other reason for this is that the main() that's written at runtime
adds some options to tell the sketch to talk to the editor. (e.g. the
editor window location will be forgotten).

buuut.. if you're gonna overwrite main(), then we may as well let you break
your code. so i've made the change to simply run the main as provided, if
the user has created their own.