Bug 573044 part2- Don't draw arc if height or width equals to zero
- No-op when arcAngle is zero on GTK.
- For consistency purpose, adding same set of checks for
width/height/arcAngle on Windows and MAC Path#addArc() methods as well.
Change-Id: Ib71f2da40e74e81007dfe217e7f67df411dc2b33
Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/179864
Tested-by: Platform Bot <platform-bot@eclipse.org>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java
index f8fe7d3..d7ca68d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -218,7 +218,7 @@
*/
public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
- if (width == 0 || height == 0) return;
+ if (width == 0 || height == 0 || arcAngle == 0) return;
x = DPIUtil.autoScaleUp(x);
y = DPIUtil.autoScaleUp(y);
width = DPIUtil.autoScaleUp(width);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Path.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Path.java
index 0f99be1..d46035b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Path.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Path.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -225,6 +225,7 @@
*/
public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+ if (width == 0 || height == 0 || arcAngle == 0) return;
NSAutoreleasePool pool = null;
if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
try {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java
index 9ce1e1d..09d50d0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -199,6 +199,7 @@
* </ul>
*/
public void addArc (float x, float y, float width, float height, float startAngle, float arcAngle) {
+ if (width == 0 || height == 0 || arcAngle == 0) return;
Drawable drawable = getDevice();
x = DPIUtil.autoScaleUp(drawable, x);
y = DPIUtil.autoScaleUp(drawable, y);
@@ -217,7 +218,6 @@
y = y + height;
height = -height;
}
- if (width == 0 || height == 0 || arcAngle == 0) return;
if (width == height) {
Gdip.GraphicsPath_AddArc(handle, x, y, width, height, -startAngle, -arcAngle);
} else {