I'm trying to draw an image in a SuperCollider GUI, but I keep getting this error message, despite having enough space to draw the image in a UserView:
ERROR: Qt: Usage of QPen is not allowed at this point!
ERROR: Primitive '_QPen_DrawImage' failed.
The code:
(
var path = CleffView.path; // this part is local to my machine, but any img will work
b = Image.new(path +/+ "B.png");
a = [b];
u = UserView();
u.drawFunc_({
var width, height, left=0, top=0;
a.do({|img|
img.notNil.if({
width = img.width;
height = img.height;
img.drawInRect(Rect(left, top, width, height),
nil, 'sourceOver', 1);
Pen.draw;
left= left + width;
});
})
})
)
Then, later:
a = a ++ b;
u.draw; // This line causes the error
UserView
s have a method called draw
, but you are not meant to invoke it. It works sometimes, but calling it from other points in the code will throw this error. Don't use it. To redraw your UserView, use a refresh
message instead.
So the later code should be:
a = a ++ b;
u.refresh;
This will throw a similar error for anything in your drawFunc
.