| Summary: | [Widget] Removing client listener twice leads to client side error | ||
|---|---|---|---|
| Product: | [RT] RAP | Reporter: | Sebastian Habenicht <dev> |
| Component: | RWT | Assignee: | Project Inbox <rap-inbox> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | 3.5 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| See Also: |
https://git.eclipse.org/r/130314 https://git.eclipse.org/c/rap/org.eclipse.rap.git/commit/?id=205aafdd9f61cb57eefb50dee415cb64353dba30 |
||
| Whiteboard: | |||
New Gerrit change created: https://git.eclipse.org/r/130314 Gerrit change https://git.eclipse.org/r/130314 was merged to [master]. Commit: http://git.eclipse.org/c/rap/org.eclipse.rap.git/commit/?id=205aafdd9f61cb57eefb50dee415cb64353dba30 |
Removing the same client listener more than once from a widget within the same render request leads to a client side error: Error: Error: Operation "call" on target "w3" of type "rwt.widgets.Text" failed: rwt.qx.Target: removeEventListener(keypress): 'undefined' is not a function! Example: public class HelloWorld extends AbstractEntryPoint { @Override protected void createContents(final Composite parent) { //create test widgets final Text text1 = new Text(parent, SWT.BORDER); final Text text2 = new Text(parent, SWT.BORDER); //add client listener to first text final ClientListener clientListener = new ClientListener( "function handleEvent(event) { console.log('key down'); }"); text1.addListener(SWT.KeyDown, clientListener); //remove client listener when first text looses focus and also when second text gains focus text1.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent event) { text1.removeFocusListener(this); text1.removeListener(SWT.KeyDown, clientListener); } }); text2.addFocusListener(new FocusAdapter() { @Override public void focusGained(final FocusEvent event) { text2.removeFocusListener(this); text1.removeListener(SWT.KeyDown, clientListener); } }); } } No such error occurs when trying the same with a server side listener, so it might be good to adjust the behavior for both types of listeners. Maybe in ClientListenerUtil, a new RemoveListener operation should only added to the widget's list of ClientListenerOperations if that list does not already contain a RemoveListener operation for the same listener.