Bug 564977

Summary: Internal cache being held
Product: [Eclipse Project] Platform Reporter: Mario Marinato <mariomarinato>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: loskutov
Version: 4.14   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard:

Description Mario Marinato CLA 2020-07-06 11:32:42 EDT
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 (bug 339132). 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.
Comment 1 Andrey Loskutov CLA 2020-07-06 16:00:13 EDT

*** This bug has been marked as a duplicate of bug 543796 ***