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

Bug 464455

Summary: [CKEditor] JS error occurs when ckeditor is used in dialog
Product: [RT] RAP Reporter: David Song <micromms>
Component: IncubatorAssignee: Project Inbox <rap.incubator-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.3   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description David Song CLA 2015-04-11 20:53:14 EDT
when I insert a ckeditor in the tabfolder in a dialog, errors occor when I click the ok button or close the dialog window, and the code is as below:

private void createEditor(TabFolder tabFolder) {
		TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
		tabItem.setText("Description");
		
		Composite composite = new Composite(tabFolder, SWT.NONE);
		tabItem.setControl(composite);
		
		composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create());
		
		CKEditor editor = new CKEditor(composite, SWT.BORDER);
		editor.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).create());
	}

and the error message in firefox is:


Error: Error: Operation "destroy" on target "r197" of type "[object Object]" failed:
this.editor is undefined
Properties: 


  Script: {"head":{"requestCounter":18},"operations":[["destroy","w174"],["destroy","w184"],["destroy","w181"],["set","w2",{"active":true}],["set","w1",{"focusControl":"w129"}],["destroy","r197"]]}
  Stack: rwt.remote.MessageProcessor._processError@DropDown.js:66636:11
rwt.remote.MessageProcessor.processOperationArray@DropDown.js:66477:7
rwt.remote.MessageProcessor.processMessage@DropDown.js:66430:7
.members._handleSuccess@DropDown.js:67121:9
rwt.remote.Request.prototype.setSuccessHandler/this._success@DropDown.js:33252:35
rwt.remote.Request.prototype._onReadyStateChange@DropDown.js:33303:13
.statics.bind/wrap@DropDown.js:3751:21

  Debug: on
  Request: {"head":{"requestCounter":17},"operations":[["set","w174",{"activeControl":"w174"}],["notify","w174","Close",{}],["set","w1",{"cursorLocation":[1022,23],"focusControl":"w174"}]]}

error message in Chrome is:

Error: Error: Operation "destroy" on target "r145" of type "[object Object]" failed:
Cannot read property 'destroy' of undefined
Properties: 


  Script: {"head":{"requestCounter":5},"operations":[["destroy","w122"],["destroy","w132"],["destroy","w129"],["set","w2",{"active":true}],["set","w1",{"focusControl":"w104"}],["destroy","r145"]]}
  Stack: Error: Operation "destroy" on target "r145" of type "[object Object]" failed:
Cannot read property 'destroy' of undefined
Properties: 

    at Object.rwt.remote.MessageProcessor._processError (DropDown.js:66636:11)
    at Object.rwt.remote.MessageProcessor.processOperationArray (DropDown.js:66477:12)
    at Object.rwt.remote.MessageProcessor.processMessage (DropDown.js:66430:12)
    at rwt.qx.Class.define.members._handleSuccess (DropDown.js:67121:19)
    at Object._success (DropDown.js:33252:43)
    at Object.rwt.remote.Request._onReadyStateChange (DropDown.js:33303:18)
    at XMLHttpRequest.wrap (DropDown.js:3751:25)
  Debug: on
  Request: {"head":{"requestCounter":4},"operations":[["set","w122",{"activeControl":"w147"}],["notify","w147","Selection",{"button":1,"shiftKey":false,"ctrlKey":false,"altKey":false}],["set","w1",{"cursorLocation":[847,598],"focusControl":"w147"}]]}


I tested the ckeditor 1.0.0 for rap 2.3.1 in Chrome and Firefox
jdk 1.7

Thank you
Comment 1 David Song CLA 2015-04-11 20:53:45 EDT
I changed the code like below in destroy function and everything is ok.

destroy : function() {
      rap.off( "send", this.onSend );
      if(this.editor){
	      this.editor.destroy();
	      this.element.parentNode.removeChild( this.element );
	  }
    }
Comment 2 Ivan Furnadjiev CLA 2015-04-14 03:56:03 EDT
The client-side CKEditor is disposed twice in this case - once indirectly by disposing (destroying) the parent (Shell) and once by itself.
Comment 3 Ivan Furnadjiev CLA 2015-04-14 05:12:38 EDT
Fixed in master with commit 6d3079abcc64c8dffb2e0dab1b0f374d893fc6b9.