Commit dd86ad5e authored by ogg.k.ogg.k's avatar ogg.k.ogg.k
Browse files

synchronize renderer methods - you don't really want to add an item

 while you are rendering the items list
parent 06db3036
......@@ -30,7 +30,7 @@ public class Renderer {
/**
* Add a new event to the renderer.
*/
public void add(com.fluendo.jkate.Event ev) {
public synchronized void add(com.fluendo.jkate.Event ev) {
items.addElement(new Item(ev));
dirty = true;
}
......@@ -39,7 +39,7 @@ public class Renderer {
* Update the renderer, and all the events it tracks.
* Returns 1 if there is nothing to draw, as an optimization
*/
public int update(Component c, Dimension d, double t) {
public synchronized int update(Component c, Dimension d, double t) {
for (int n=0; n<items.size(); ++n) {
boolean ret = ((Item)items.elementAt(n)).update(c, d, t);
if (!ret) {
......@@ -61,7 +61,7 @@ public class Renderer {
/**
* Renders onto the given image.
*/
public Image render(Component c, Image img) {
public synchronized Image render(Component c, Image img) {
/* there used to be some non copying code using BufferedImage, but that's not in SDK 1.1, so we do it the slow way */
Image copy = c.createImage(img.getWidth(null), img.getHeight(null));
Graphics g = copy.getGraphics();
......@@ -81,12 +81,12 @@ public class Renderer {
/**
* Flushes all events.
*/
public void flush() {
public synchronized void flush() {
items.removeAllElements();
dirty = true;
}
public boolean isDirty() {
public synchronized boolean isDirty() {
return dirty;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment