[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.ve] shell close() stack overflow

Running an SWT application (created in VE 1.1) on Windows causes a StackOverflowError when running inside the Eclipse IDE. The shell event listener listens for a close event. When closing the app via the "X" close button in the upper right of the window, it continually loops on the calling the shellClosed() listener method over and over, finally choking on itself. Should I completely remove the call to sShell.close(). Why? See the sample program below. Try it. Thanks for any responses!

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.SWT;

public class testblah {

	private Shell sShell = null;

	public static void main(String[] args) {
		Display display = Display.getDefault();
		testblah thisClass = new testblah();
		thisClass.createSShell();
		thisClass.sShell.open();

		while (!thisClass.sShell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}

	private void createSShell() {
		sShell = new Shell();
		sShell.setText("Shell");
		sShell.setSize(new Point(300, 200));
		sShell.addShellListener(new org.eclipse.swt.events.ShellAdapter() {
			public void shellClosed(org.eclipse.swt.events.ShellEvent e) {
				sShell.close();
				sShell.dispose();
			}
		});
	}
}