Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342516 - Could not evaluate javascript response if open/close dialogs
Summary: Could not evaluate javascript response if open/close dialogs
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.4   Edit
Hardware: All All
: P2 normal (vote)
Target Milestone: 1.4 M7   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 233013 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-04-12 04:26 EDT by Steffen CLA
Modified: 2011-04-13 03:26 EDT (History)
3 users (show)

See Also:


Attachments
Package to reproduce the bug. (2.79 KB, application/x-zip-compressed)
2011-04-12 04:26 EDT, Steffen CLA
no flags Details
Proposed patch. (2.17 KB, patch)
2011-04-12 15:11 EDT, Ivan Furnadjiev CLA
no flags Details | Diff
Updated patch with JUnit test (15.52 KB, patch)
2011-04-12 17:09 EDT, Ivan Furnadjiev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steffen CLA 2011-04-12 04:26:58 EDT
Created attachment 193010 [details]
Package to reproduce the bug.

If you open and close dialogs in a specific way, it can lead to a crash of a javascript response with the following error message:
---
Could not evaluate javascript response:

Error: TypeError: w is undefined

  Script: var wm = org.eclipse.swt.WidgetManager.getInstance();var w = wm.findWidgetById( "w173" );w.doClose();wm.dispose( "w173" );var w = wm.findWidgetById( "w222" );w.doClose();wm.dispose( "w222" );wm.dispose( "w223" );wm.dispose( "w236" );wm.dispose( "w235" );wm.dispose( "w234" );wm.dispose( "w233" );wm.dispose( "w232" );wm.dispose( "w231" );wm.dispose( "w224" );wm.dispose( "w229" );wm.dispose( "w230" );wm.dispose( "w206" );wm.dispose( "w205" );wm.dispose( "w225" );wm.dispose( "w227" );wm.dispose( "w228" );wm.dispose( "w226" );var req = org.eclipse.swt.Request.getInstance();req.setRequestCounter( "8" );var w = wm.findWidgetById( "w207" );w.setActive( true );org.eclipse.swt.WidgetManager.getInstance().focus( "w208" );
  message: w is undefined
  stack: not relevant

  fileName: not relevant
  lineNumber: 56946
  name: TypeError
  Debug: on
  Request: w222.activeControl=w205&org.eclipse.swt.events.widgetSelected=w205&w1.cursorLocation.x=709&w1.cursorLocation.y=396&w1.focusControl=w205&uiRoot=w1&requestCounter=7
---

To reproduce this you can find a source-package in the attachment named test.

There you can find three files:
1. TestQueue.java
2. TestEdit.java
3. TestEditPre.java

Short description of the source/use:
First of all an instance of the TestQueue (dialog) will be created. It contains a button "start". By clicking on the button it will be repeatly create and open an instance of TestEdit (also a dialog) by calling method doTestEdit. The shell of TestEdit gets a dispose-listener. If the listener gets an event it trys to close the old TestEdit-dialog and open a new one by calling doTestEdit-method. 
The TestEdit-shell is not blocked on open. The open-method of TestEdit creates an instance of TestEditPre which will be instantly opened in the open-method of TestEdit. The shell of TestEditPre is blocked on open. 
By clicking ok or cancel in TestEditPre-dialog the dialog will be closed. By clicking ok or cancel in the TestEdit-dialog the dispose-listener gets an event and it creates/opens a new TestEdit-dialog by calling doTestEdit-method. Now, if you click ok or cancel in the new TestEditPre-dialog you get the error message above.

Remark: If you remove the creation of TestEditPre-dialog you do not get any error messages so the problem seems to be at this position.
Comment 1 Steffen CLA 2011-04-12 04:48:06 EDT
Steps to reproduce:
1. Click on button start in the TestQueue-dialog
2. Click ok or cancel in TestEditPre-dialog
3. Click or or cancel in TestEdit-dialog
4. Click ok or cancel in new TestEditPre-dialog
5. now you get the error message
Comment 2 Rüdiger Herrmann CLA 2011-04-12 05:24:18 EDT
Please specify what version you are using.
Comment 3 Steffen CLA 2011-04-12 05:49:59 EDT
RWT 1.4M5
But i have also tested against M6 with the same issue.
Comment 4 Ivan Furnadjiev CLA 2011-04-12 10:52:57 EDT
I can reproduce the error with your snippet and CVS HEAD.
Comment 5 Ivan Furnadjiev CLA 2011-04-12 12:19:19 EDT
Steffen, I think that your code is not so correct. You dispose a shell ( call testEdit.close() ) in the DisposeEvent if the same Shell. Your code could be transformed into this:
shell.addDisposeListener(new DisposeListener() {
  public void widgetDisposed(DisposeEvent event) {
    shell.dispose();
    new Dialog().open();
  }
} );
Nevertheless, I will check how SWT handle disposing of a widget in widgetDisposed event of the same widget. Note, that in widgetDisposed event the widget.isDisposed() still returns false.
Comment 6 Ivan Furnadjiev CLA 2011-04-12 15:11:57 EDT
Created attachment 193085 [details]
Proposed patch.

This patch gets use of Widget RELEASE flag in the same way like in SWT. JUnit tests will follow.
Comment 7 Ivan Furnadjiev CLA 2011-04-12 15:32:47 EDT
*** Bug 233013 has been marked as a duplicate of this bug. ***
Comment 8 Ivan Furnadjiev CLA 2011-04-12 17:09:40 EDT
Created attachment 193097 [details]
Updated patch with JUnit test
Comment 9 Ivan Furnadjiev CLA 2011-04-13 03:26:17 EDT
Applied patch to CVS HEAD.