processing/processing

Tweak mode failing to start with particular comments in and around setup()

已關閉

#4,125 建立於 2015年11月9日

 (2 則留言) (0 個反應) (0 位負責人)Java (1,540 個分叉)batch import
help wantedtweak

倉庫指標

星標
 (6,431 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Hi, I've found some cases where Tweak Mode causes an error to be raised on a normally runnable sketch or where the tweak controls fail to appear.

I'm using Processing 3.0.1 on Arch Linux 64-bit.

This sketch:

/*
void setup() {
}
*/

void setup()
{
    size(640, 360);
}

void draw()
{
    background(#ff0000);
}

runs okay giving an empty window filled with red, but when I select Sketch -> Tweak I get this error:


java.lang.IllegalArgumentException: Width (0) and height (0) cannot be <= 0
    at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1016)
    at java.awt.GraphicsConfiguration.createCompatibleImage(GraphicsConfiguration.java:186)
    at processing.awt.PGraphicsJava2D.checkImage(PGraphicsJava2D.java:318)
    at processing.awt.PGraphicsJava2D.beginDraw(PGraphicsJava2D.java:328)
    at processing.core.PApplet.handleDraw(PApplet.java:2361)
    at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1527)
    at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)

It seems like Processing is getting confused by the commented out setup() function at the top. If you remove this, Tweak Mode works OK. If you rename the commented out setup() function to eg. setup2(), it also works OK. If you leave it called setup() and instead of commenting it out as a block (with /* and */), comment it out one line at a time (with //), then it raises the same error.

Here's another sample sketch where Tweak Mode fails to start with the same error:

void setup()
// This function is called once, when the program starts.
{
    size(600, 500);
}

void draw()
{
    background(#ff0000);
}

Here there is only one setup(), but it seems to have got confused by the comment between setup() and the opening '{'. If you remove that comment then Tweak Mode starts OK.

By the way, in both of the above sketches, the above error is only raised if the real setup() contains a call to size(). If you remove that line, then you don't get the error - however, then you don't get the tweak control next to the background() call either - I'll write this one up as a seperate bug shortly.

貢獻者指南