I'm developing an application using Eclipse and SWT. If I do the following on a mac, the second file has the same contents as the first one. There was a bug in SWT that was solved nearly a decade ago that was related with how swt.GC was disposed. But in my case it's not being disposed.
It seems there's a cache being held somewhere, but I couldn't find a way to get rid of it.
My code, simplified:
Image myImg = new Image( Display.getDefault(), 100, 100 );
GC mygc = new GC( myImg );
// draw something
// Saves the image to a file.
saveImage( myImg );
// draw something else on the same image.
// Saves the image to another file.
saveImage( myImg );
myImg.dispose();
mygc.dispose();
If I do this after saving the first file, and before the extra drawing operations, the problem is solved:
mygc.dispose();
mygc = new GC( myImg );
But I don't want to dispose and create a new GC, because of performance issues. On Windows it works perfectly.