From 8d677bd992b4b0015671df61ae85c3a040e35fc2 Mon Sep 17 00:00:00 2001 From: Andreas Koch Date: Tue, 25 Feb 2025 17:15:16 +0100 Subject: [PATCH] Remove obsolete hashCode/equals for Region This commit adapt the obsolete equals and hashCode methods for Region to use the super implementation instead. For the upcoming changes for win32 the current implementation cannot be used anymore because all handles will be created on demand. As the current implementation is equal in their behavior to the base behavior for these methods is inherited from Object. --- .../Eclipse SWT/cocoa/org/eclipse/swt/graphics/Region.java | 6 ++---- .../Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java | 7 ++----- .../Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java | 7 ++----- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Region.java index 7dbe8e518c5..0e7efe4ad74 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Region.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Region.java @@ -436,9 +436,7 @@ void destroy() { */ @Override public boolean equals(Object object) { - if (this == object) return true; - if (!(object instanceof Region region)) return false; - return handle == region.handle; + return super.equals(object); } /** @@ -511,7 +509,7 @@ long regionToRects(long message, long rgn, long r, long path) { */ @Override public int hashCode() { - return (int)handle; + return super.hashCode(); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java index 283d19df049..f33de0b3a9c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java @@ -310,10 +310,7 @@ void destroy() { */ @Override public boolean equals(Object object) { - if (this == object) return true; - if (!(object instanceof Region)) return false; - Region region = (Region)object; - return handle == region.handle; + return super.equals(object); } /** @@ -371,7 +368,7 @@ public static Region gtk_new(Device device, long handle) { */ @Override public int hashCode() { - return (int)handle; + return super.hashCode(); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java index 5203a26e058..2662703aed7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java @@ -253,10 +253,7 @@ void destroyHandlesExcept(Set zoomLevels) { */ @Override public boolean equals (Object object) { - if (this == object) return true; - if (!(object instanceof Region)) return false; - Region rgn = (Region)object; - return getHandleForInitialZoom() == rgn.getHandleForInitialZoom(); + return super.equals(object); } /** @@ -295,7 +292,7 @@ Rectangle getBoundsInPixels() { */ @Override public int hashCode () { - return (int)getHandleForInitialZoom(); + return super.hashCode(); } /**