diff options
author | Jonah Graham | 2020-05-21 21:37:15 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2020-06-11 00:59:17 +0000 |
commit | 6ec8f744d362c041988a8af838fb00d0ec7af904 (patch) | |
tree | a7892f52510a33641cbe33b08860188e6f09169f | |
parent | c1c41c99b7c38f45c7c9e1e199d2b4036a83d7eb (diff) | |
download | eclipse.platform.swt-6ec8f744d362c041988a8af838fb00d0ec7af904.tar.gz eclipse.platform.swt-6ec8f744d362c041988a8af838fb00d0ec7af904.tar.xz eclipse.platform.swt-6ec8f744d362c041988a8af838fb00d0ec7af904.zip |
Bug 563560: Don't report Colors in S-Leak allocated resources
Now that there is no requirement to dispose of colors, they can fill
the list of items that require disposal when using S-Leak. This
patch does not report Colors anymore.
A separate patch does not record the Colors in the first place.
Change-Id: I4842abf1e436bd60e052f101f003b73b604df660
Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
-rw-r--r-- | bundles/org.eclipse.swt.tools.spies/src/org/eclipse/swt/tools/internal/Sleak.java | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/bundles/org.eclipse.swt.tools.spies/src/org/eclipse/swt/tools/internal/Sleak.java b/bundles/org.eclipse.swt.tools.spies/src/org/eclipse/swt/tools/internal/Sleak.java index 5402064eed..6dc715a81b 100644 --- a/bundles/org.eclipse.swt.tools.spies/src/org/eclipse/swt/tools/internal/Sleak.java +++ b/bundles/org.eclipse.swt.tools.spies/src/org/eclipse/swt/tools/internal/Sleak.java @@ -107,10 +107,9 @@ public void create (Composite parent) { } void refreshLabel () { - int colors = 0, cursors = 0, fonts = 0, gcs = 0, images = 0; + int cursors = 0, fonts = 0, gcs = 0, images = 0; int paths = 0, patterns = 0, regions = 0, textLayouts = 0, transforms= 0; for (Object object : objects) { - if (object instanceof Color) colors++; if (object instanceof Cursor) cursors++; if (object instanceof Font) fonts++; if (object instanceof GC) gcs++; @@ -122,7 +121,6 @@ void refreshLabel () { if (object instanceof Transform) transforms++; } String string = ""; - if (colors != 0) string += colors + " Color(s)\n"; if (cursors != 0) string += cursors + " Cursor(s)\n"; if (fonts != 0) string += fonts + " Font(s)\n"; if (gcs != 0) string += gcs + " GC(s)\n"; @@ -148,8 +146,23 @@ void refreshDifference () { dialog.setMessage ("Warning: Device is not tracking resource allocation"); dialog.open (); } - Object [] newObjects = info.objects; - Error [] newErrors = info.errors; + int size = 0; + for (int i = 0; i < info.objects.length; i++) { + if (!(info.objects[i] instanceof Color)) { + size++; + } + } + Object [] newObjects = new Object[size]; + Error [] newErrors = new Error[size]; + for (int i = 0, out_i = 0; i < info.objects.length; i++) { + // Bug 563018: Colors don't require disposal, so exclude + // them from the list of allocated objects. + if (!(info.objects[i] instanceof Color)) { + newObjects[out_i] = info.objects[i]; + newErrors[out_i] = info.errors[i]; + out_i++; + } + } Object [] diffObjects = new Object [newObjects.length]; Error [] diffErrors = new Error [newErrors.length]; int count = 0; @@ -264,12 +277,6 @@ void paintCanvas (Event event) { } void draw(GC gc, Object object) { - if (object instanceof Color) { - if (((Color)object).isDisposed ()) return; - gc.setBackground ((Color) object); - gc.fillRectangle (canvas.getClientArea()); - return; - } if (object instanceof Cursor) { if (((Cursor)object).isDisposed ()) return; canvas.setCursor ((Cursor) object); |