Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 465413

Summary: Callback deregistration (rap.off) deletes wrong callback if called multiple times
Product: [RT] RAP Reporter: Martin Domig <martin>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ivan
Version: 2.3   
Target Milestone: 3.0 M7   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch that will make possible to call rap.off() multiple times without side effects ivan: iplog+

Description Martin Domig CLA 2015-04-24 08:39:13 EDT
Created attachment 252731 [details]
Patch that will make possible to call rap.off() multiple times without side effects

We use 2 different custom widgets, both of which use a RAP render callback.

One of those widgets de-registeres its render callback on the first call:

myRender : function() {
  rap.off('render', this.myRender);
  // ... some irrelevant stuff here ...
}


In some circumstances it can happen that the myRender function is called twice (or more times). To reproduce with any custom widget, just duplicate the rap.off() line.

On the second call, rap.off() will call rwt.util.Arrays.removeAt( array, index ) with -1 as index, resulting in the callback of the other custom widget being removed.

The fix is simple and is actually implemented in the rap.on function just above: do nothing if the index is -1.

Patch against 2.3-maintenance attached.
Comment 1 Ivan Furnadjiev CLA 2015-04-28 03:57:46 EDT
Thanks for the investigation and the patch. Pending change for RAP 3.0 is waiting the review - https://git.eclipse.org/r/#/c/46639/.
Comment 2 Ivan Furnadjiev CLA 2015-04-28 08:17:29 EDT
Change https://git.eclipse.org/r/#/c/46639/ has been merged.