Bug 564978 - Internal cache being held
Summary: Internal cache being held
Status: CLOSED DUPLICATE of bug 543796
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.14   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-06 11:33 EDT by Mario Marinato CLA
Modified: 2020-07-06 15:59 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mario Marinato CLA 2020-07-06 11:33:08 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 Phil Beauvoir CLA 2020-07-06 12:06:53 EDT
Is it this issue?

https://bugs.eclipse.org/bugs/show_bug.cgi?id=543796
Comment 2 Mario Marinato CLA 2020-07-06 13:41:16 EDT
Yeah, precisely!  

The example I put on my description comes from tests I was making, but the real problem I'm having is that our images do not get updated after being drawn on another one, just like the spinnet from the bug you linked.

On my example above, as I'm testing from our RCP product, I save my file doing this:

ImageLoader iLoader = new ImageLoader();
iLoader.data = new ImageData[] { image.getImageData() };
iLoader.save( Platform.getLocation().toOSString() + File.separator + Long.toString( System.currentTimeMillis() ) + ".png", SWT.IMAGE_PNG );

How can I create a snippet that saves to a file without specifying an absolute path?
Comment 3 Andrey Loskutov CLA 2020-07-06 15:59:45 EDT

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