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

Bug 511037

Summary: Error due to explicit creation of a ToolTip widget
Product: [RT] RAP Reporter: Gunnar Adams <Gunnar.Adams>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: 3.1   
Target Milestone: 3.2 M5   
Hardware: PC   
OS: Windows 7   
See Also: https://git.eclipse.org/r/89580/
Whiteboard:

Description Gunnar Adams CLA 2017-01-25 10:06:56 EST
I have been investigating a bug in our application and think, that I have found a potential error in the RAP-Client code.

In the application, we use the Tooltip widget in order to display messages to the user. 
We create those tooltips as children of the main application window (a Shell) with the SWT.BALLOON style, setAutoHide(false).
When such a tooltip has been displayed by our application, the destruction of the main application window on exit out of the application, will result in an error 

Error: Operation "destroy" on target "w2" of type "null" failed:
objectEntry is undefined.

"w2" is the id of the Shell widget being destroyed. The object whose entry is undefined is the ToolTip widget, which has already been disposed by the application a long time before closing the Shell window.

I debugged the Javascript code and found, that the Tooltip widget is added to the destroyableChildren list of the owning Shell, but is never removed from that list when the Tooltip widget is disposed. This is due to the fact that in TooltipHandler.js the protocolParent isn't set. rwt.remote.HandlerUtil.addDestroyableChild(parent, result) is called, though. removeDestroyableChild is never called, because protocolParent is null.

For some reason, for the normal Tooltip behavior displaying hints on/for another widget does not add the ToolTip to the destroyableChildren list.

The following fix to ToolTipHandler.js seems to work fine:

rwt.remote.HandlerRegistry.add( "rwt.widgets.ToolTip", {

  factory : function( properties ) {
    var styleMap = rwt.remote.HandlerUtil.createStyleMap( properties.style );
    var style = null;
    if( styleMap.ICON_ERROR ) {
      style = "error";
    } else if( styleMap.ICON_WARNING ) {
      style = "warning";
    } else if( styleMap.ICON_INFORMATION ) {
      style = "information";
    }
    var result = new rwt.widgets.ToolTip( style );
    result.setMarkupEnabled( properties.markupEnabled === true );
    rwt.remote.HandlerUtil.addStatesForStyles( result, properties.style );
    rwt.remote.HandlerUtil.callWithTarget( properties.parent, function( parent ) {
      rwt.remote.HandlerUtil.addDestroyableChild( parent, result );
     [color=orangered] result.setUserData("protocolParent", parent);[/color]
    } );
    return result;
  },
Comment 1 Ivan Furnadjiev CLA 2017-01-26 07:49:37 EST
Fixed with change https://git.eclipse.org/r/#/c/89580/