From baf39c849b01196b63fca5ed128b93838d796c93 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Fri, 4 Sep 2015 13:04:50 +0200 Subject: [PATCH] [FIX] reference errors in gecko browsers when having the ckeditor in a popup and closing it --- web_ckeditor4/static/src/js/web_ckeditor4.js | 27 ++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/web_ckeditor4/static/src/js/web_ckeditor4.js b/web_ckeditor4/static/src/js/web_ckeditor4.js index 7f78dba5..7af40c6b 100644 --- a/web_ckeditor4/static/src/js/web_ckeditor4.js +++ b/web_ckeditor4/static/src/js/web_ckeditor4.js @@ -47,6 +47,21 @@ openerp.web_ckeditor4 = function(instance) } return ckeditor_addFunction_org(fn, scope); }; + var ckeditor_setTimeout_org = CKEDITOR.tools.setTimeout, + ckeditor_timeouts = {}; + //we need to collect timeouts in order to cancel them to avoid errors on + //cleaning up + CKEDITOR.tools.setTimeout = function(func, milliseconds, scope, args, ownerWindow) + { + var result = ckeditor_setTimeout_org.apply(this, arguments); + console.log(arguments); + if(!ckeditor_timeouts[scope]) + { + ckeditor_timeouts[scope] = []; + } + ckeditor_timeouts[scope].push(result); + return result; + } CKEDITOR.on('dialogDefinition', function(e) { @@ -199,8 +214,16 @@ openerp.web_ckeditor4 = function(instance) { if(this.editor) { - this.editor.removeAllListeners(); - this.editor.destroy(); + this.editor._.editable = null; + this.editor.destroy(true); + if(ckeditor_timeouts[this.editor]) + { + _.each(ckeditor_timeouts[this.editor], function(timeout) + { + clearTimeout(timeout); + }); + delete ckeditor_timeouts[this.editor]; + } this.editor = null; } },