Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Display.java4
-rw-r--r--tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/Shell_Test.java43
2 files changed, 45 insertions, 2 deletions
diff --git a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Display.java
index 66a755026c..2b0f020e38 100644
--- a/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Display.java
@@ -776,7 +776,9 @@ public class Display extends Device implements Adaptable {
shells.add( activeShell );
}
ShellEvent shellEvent;
- if( lastActiveShell != null ) {
+ if( lastActiveShell != null
+ && ( lastActiveShell.state & Widget.DISPOSE_SENT ) == 0 )
+ {
shellEvent = new ShellEvent( lastActiveShell,
ShellEvent.SHELL_DEACTIVATED );
shellEvent.processEvent();
diff --git a/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/Shell_Test.java b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/Shell_Test.java
index ce37aa9a0b..f1448d2eed 100644
--- a/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/Shell_Test.java
+++ b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/Shell_Test.java
@@ -22,6 +22,7 @@ import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.widgets.IShellAdapter;
+import org.eclipse.swt.layout.FillLayout;
public class Shell_Test extends TestCase {
@@ -355,7 +356,8 @@ public class Shell_Test extends TestCase {
* 278996: [Shell] Stackoverflow when closing child shell
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=278996
*/
- public void testCloseOnDeactivate() {
+ public void testCloseOnDeactivateWithSingleShell() {
+ RWTFixture.fakePhase( PhaseId.PROCESS_ACTION );
Display display = new Display();
final Shell shell = new Shell( display );
shell.addShellListener( new ShellAdapter() {
@@ -368,6 +370,45 @@ public class Shell_Test extends TestCase {
// no assert: test case is to ensure that no stack overflow occurs
}
+ /*
+ * Bug 282506: [Shell] StackOverflow when calling Shell#close in Deactivate
+ * listener
+ */
+ public void testCloseOnDeactivateWithMultipleShells() {
+ RWTFixture.fakePhase( PhaseId.PROCESS_ACTION );
+ Display display = new Display();
+ Shell shell = new Shell( display );
+ shell.open();
+ final Shell dialog = new Shell( shell );
+ dialog.setLayout( new FillLayout() );
+ dialog.addShellListener( new ShellAdapter() {
+ public void shellDeactivated( final ShellEvent event ) {
+ dialog.close();
+ }
+ } );
+ dialog.open();
+ dialog.close();
+ // no assert: test case is to ensure that no stack overflow occurs
+ }
+
+ public void testNoDeactivateEventOnDispose() {
+ RWTFixture.fakePhase( PhaseId.PROCESS_ACTION );
+ final StringBuffer log = new StringBuffer();
+ Display display = new Display();
+ Shell shell = new Shell( display );
+ shell.addShellListener( new ShellAdapter() {
+ public void shellActivated( final ShellEvent event ) {
+ log.append( "shell activated" );
+ }
+ public void shellDeactivated( final ShellEvent event ) {
+ log.append( "shell deactivated" );
+ }
+ } );
+ shell.open();
+ shell.dispose();
+ assertEquals( "shell activated", log.toString() );
+ }
+
public void testMaximized() {
Display display = new Display();
Shell shell = new Shell( display );

Back to the top