From 40924de4459123749467134859c37af273db54bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Tue, 23 Sep 2025 09:11:21 +0300 Subject: [PATCH] Stackoverflow fix in ImageDescriptor Fixes getImageData(100) calling itself endlessly (introduced via https://github.com/eclipse-platform/eclipse.platform.ui/commit/c2fe1447c499d0de02b24e5bd07e18d559105e0e ) by reintroducing the bigger getImageData(100) and getImageData() endlessly (introduced in 2017 via https://github.com/eclipse-platform/eclipse.platform.ui/commit/e6d12ca0ae4762273680dc65ae8eb6f211778acc ) that wasn't experienced thanks to the *happy accident* that it was asbtract method and all implementations before that had their own and every implementor since then most likely figured the endless loop while developing. Enhanced documentation to mention that. --- .../jface/resource/ImageDescriptor.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/ImageDescriptor.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/ImageDescriptor.java index c2f3282e3e9..23eae314c9a 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/ImageDescriptor.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/resource/ImageDescriptor.java @@ -424,30 +424,32 @@ public Image createImage(boolean returnMissingImageOnError, Device device) { */ public ImageData getImageData(int zoom) { if (zoom == 100) { - return getImageData(100); + return getImageData(); } return null; } /** - * Creates and returns a new SWT ImageData object - * for this image descriptor. - * Note that each call returns a new SWT image data object. + * Creates and returns a new SWT ImageData object for this image + * descriptor. Note that each call returns a new SWT image data object. *

- * This framework method is declared public so that it is - * possible to request an image descriptor's image data without - * creating an SWT image object. + * This framework method is declared public so that it is possible to request an + * image descriptor's image data without creating an SWT image object. *

*

* Returns null if the image data could not be created. *

*

- * This method was abstract until 3.13. Clients should stop re-implementing - * this method and should re-implement {@link #getImageData(int)} instead. + * This method was abstract until 3.13. Clients should stop re-implementing this + * method and should re-implement {@link #getImageData(int)} instead. *

* * @return a new image data or null - * @deprecated Use {@link #getImageData(int)} instead. + * @deprecated Replace with {@link #getImageData(int)} instead. Note: Calling + * this method may result in stack overflow if subclass doesn't + * override either {@link #getImageData()} or + * {@link #getImageData(int)} to prevent endless cycle between the 2 + * implementation in this class since 2017. */ @Deprecated public ImageData getImageData() {