Bug 565209: Stop tracking Colors in Device

Tracking Colors in Device causes a memory leak and misreporting of
Colors as using Resources.

Change-Id: I19e1476368eb1e4bf3debe7b770d0b073d289296
Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Color.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Color.java
index 9e3b18e..ed05e81 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Color.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Color.java
@@ -275,8 +275,12 @@
  */
 @Override
 public void dispose() {
-	super.dispose();
+	// Does as below to maintain API contract with Resource. Does
+	// not use super.dispose() because that untracks the Color
+	// from the Device tracking, however init() is overridden
+	// to prevent the tracking in the first place.
 	destroy();
+	device = null;
 }
 
 /**
@@ -497,6 +501,14 @@
 	handle = rgbColor;
 }
 
+@Override
+void init() {
+	// Resource init simply tracks this resource in the Device
+	// if DEBUG is on. Since Colors don't require disposal,
+	// the tracking would be a memory leak and a misreport
+	// on what resources are in use.
+}
+
 /**
  * Returns <code>true</code> if the color has been disposed,
  * and <code>false</code> otherwise.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Color.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Color.java
index e50d846..6f5c220 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Color.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Color.java
@@ -277,8 +277,12 @@
  */
 @Override
 public void dispose() {
-	super.dispose();
+	// Does as below to maintain API contract with Resource. Does
+	// not use super.dispose() because that untracks the Color
+	// from the Device tracking, however init() is overridden
+	// to prevent the tracking in the first place.
 	destroy();
+	device = null;
 }
 
 /**
@@ -513,6 +517,14 @@
 	handle = rgba;
 }
 
+@Override
+void init() {
+	// Resource init simply tracks this resource in the Device
+	// if DEBUG is on. Since Colors don't require disposal,
+	// the tracking would be a memory leak and a misreport
+	// on what resources are in use.
+}
+
 /**
  * Returns <code>true</code> if the color has been disposed,
  * and <code>false</code> otherwise.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Color.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Color.java
index 564e1db..eee9576 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Color.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Color.java
@@ -294,8 +294,12 @@
  */
 @Override
 public void dispose() {
-	super.dispose();
+	// Does as below to maintain API contract with Resource. Does
+	// not use super.dispose() because that untracks the Color
+	// from the Device tracking, however init() is overridden
+	// to prevent the tracking in the first place.
 	destroy();
+	device = null;
 }
 
 /**
@@ -461,6 +465,14 @@
 	this.alpha = alpha;
 }
 
+@Override
+void init() {
+	// Resource init simply tracks this resource in the Device
+	// if DEBUG is on. Since Colors don't require disposal,
+	// the tracking would be a memory leak and a misreport
+	// on what resources are in use.
+}
+
 /**
  * Returns <code>true</code> if the color has been disposed,
  * and <code>false</code> otherwise.