Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2017-07-26 11:38:18 +0000
committerEric Williams2017-07-26 14:40:22 +0000
commit3b7a03ad4819bd0b57a0b8cd57a7a8d1f7604e9a (patch)
tree17f013f52c112ee567bab071801fa8801dd329f5 /bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt
parent1029b84e68b0bf9e256493845a328805924cd9d1 (diff)
downloadeclipse.platform.swt-3b7a03ad4819bd0b57a0b8cd57a7a8d1f7604e9a.tar.gz
eclipse.platform.swt-3b7a03ad4819bd0b57a0b8cd57a7a8d1f7604e9a.tar.xz
eclipse.platform.swt-3b7a03ad4819bd0b57a0b8cd57a7a8d1f7604e9a.zip
Bug 477950 - make sure Color.get*() retuns values in range 0 - 255
Color.getBlue(), getRed(), detGreen() API contract is to return a value from 0 to 255. After commit 8f5c12dbbf0d52d77529e8b468c625831e5f4dd0 this constraint can be violated. This commit makes sure the returned values are always in specified range. Technical background: org.eclipse.swt.widgets.Display.getBackgroundColor(long, int) (and probably in other places?) we can read negative values, which, if returned "as is" cause Color.getRGB() to fail with IllegalArgumentException later. Ideally we would have appropriate set* methods and check the values there, but this is not the part of this commit. Change-Id: I8dc153e843c45cae9fd3f04165f33d4f39f3ab49 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Color.java6
1 files changed, 3 insertions, 3 deletions
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 fdcedb83a3..d2c50bea2e 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
@@ -293,7 +293,7 @@ public int getAlpha() {
public int getBlue() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (OS.GTK3) {
- return (int) (handleRGBA.blue * 255);
+ return (int) (handleRGBA.blue * 255) & 0xFF;
} else {
return (handle.blue >> 8) & 0xFF;
}
@@ -311,7 +311,7 @@ public int getBlue() {
public int getGreen() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (OS.GTK3) {
- return (int) (handleRGBA.green * 255);
+ return (int) (handleRGBA.green * 255) & 0xFF;
} else {
return (handle.green >> 8) & 0xFF;
}
@@ -329,7 +329,7 @@ public int getGreen() {
public int getRed() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (OS.GTK3) {
- return (int) (handleRGBA.red * 255);
+ return (int) (handleRGBA.red * 255) & 0xFF;
} else {
return (handle.red >> 8) & 0xFF;
}

Back to the top