Skip to content

Commit 422bd8b

Browse files
committed
Stackoverflow fix in ImageDescriptor
Fixes getImageData(100) calling itself endlessly (introduced via c2fe144 ) by reintroducing the bigger getImageData(100) and getImageData() endlessly (introduced in 2017 via e6d12ca ) 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.
1 parent 4f687d6 commit 422bd8b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

bundles/org.eclipse.jface/src/org/eclipse/jface/resource/ImageDescriptor.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -424,30 +424,32 @@ public Image createImage(boolean returnMissingImageOnError, Device device) {
424424
*/
425425
public ImageData getImageData(int zoom) {
426426
if (zoom == 100) {
427-
return getImageData(100);
427+
return getImageData();
428428
}
429429
return null;
430430
}
431431

432432
/**
433-
* Creates and returns a new SWT <code>ImageData</code> object
434-
* for this image descriptor.
435-
* Note that each call returns a new SWT image data object.
433+
* Creates and returns a new SWT <code>ImageData</code> object for this image
434+
* descriptor. Note that each call returns a new SWT image data object.
436435
* <p>
437-
* This framework method is declared public so that it is
438-
* possible to request an image descriptor's image data without
439-
* creating an SWT image object.
436+
* This framework method is declared public so that it is possible to request an
437+
* image descriptor's image data without creating an SWT image object.
440438
* </p>
441439
* <p>
442440
* Returns <code>null</code> if the image data could not be created.
443441
* </p>
444442
* <p>
445-
* This method was abstract until 3.13. Clients should stop re-implementing
446-
* this method and should re-implement {@link #getImageData(int)} instead.
443+
* This method was abstract until 3.13. Clients should stop re-implementing this
444+
* method and should re-implement {@link #getImageData(int)} instead.
447445
* </p>
448446
*
449447
* @return a new image data or <code>null</code>
450-
* @deprecated Use {@link #getImageData(int)} instead.
448+
* @deprecated Replace with {@link #getImageData(int)} instead. <b>Note: Calling
449+
* this method may result in stack overflow if subclass doesn't
450+
* override either {@link #getImageData()} or
451+
* {@link #getImageData(int)} to prevent endless cycle between the 2
452+
* implementation in this class since 2017.</b>
451453
*/
452454
@Deprecated
453455
public ImageData getImageData() {

0 commit comments

Comments
 (0)