diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/Dialog.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/Dialog.java index 12e534ad85b..11e5cbfdf73 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/Dialog.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/Dialog.java @@ -16,6 +16,7 @@ import java.util.Arrays; import java.util.HashMap; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import org.eclipse.core.runtime.IProgressMonitor; @@ -1109,13 +1110,24 @@ private void hookZoomChangeListenerForDefaultSizedDialogs() { } AtomicReference customResizeListener = new AtomicReference<>(); + // setSize() sends the next SWT.Resize, which calls this listener again. Without the + // re-entrancy guard the listener recurses until the stack is exhausted whenever the + // computed size is not a fixed point, e.g. because a scrollbar appears and disappears + // with it. + AtomicBoolean adaptingDefaultSize = new AtomicBoolean(); Listener adaptDefaultSizeListener = event -> { Shell shell = getShell(); - if (shell == null || shell.isDisposed()) { + if (shell == null || shell.isDisposed() || !adaptingDefaultSize.compareAndSet(false, true)) { return; } - Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); - shell.setSize(size); + try { + Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); + if (!size.equals(shell.getSize())) { + shell.setSize(size); + } + } finally { + adaptingDefaultSize.set(false); + } }; AtomicReference zoomChangeListener = new AtomicReference<>(); zoomChangeListener.set(event -> { diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/wizard/WizardDialog.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/wizard/WizardDialog.java index 562d5493509..6b83af04a29 100644 --- a/bundles/org.eclipse.jface/src/org/eclipse/jface/wizard/WizardDialog.java +++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/wizard/WizardDialog.java @@ -342,6 +342,16 @@ public int getShellStyle() { return super.getShellStyle(); } + /** + * A wizard dialog is resizable unless a caller has stripped {@link SWT#RESIZE} from its shell + * style, so the answer is read from that style instead of being inherited from + * Dialog, which always answers false. + */ + @Override + protected boolean isResizable() { + return (getShellStyle() & SWT.RESIZE) != 0; + } + private static int getShellModality(boolean modal) { return modal ? SWT.PRIMARY_MODAL : SWT.NONE; }