[pve-devel] [PATCH manager v2 2/2] ext6migrate: fix framework caching issue

Dominik Csapak d.csapak at proxmox.com
Mon Mar 14 13:41:23 CET 2016


in extjs 5/6 there is a caching issue, where they
save dom elements for reuse, but the garbage collector
can set them to null

when the framework now reuses the "cached" element it is null,
and any action on it produces an error, which breaks the site

for details see the forum link in the comment

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes from v1:
 moved from Utils.js to Toolkit.js where the other overrides are
 www/manager6/Toolkit.js | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/www/manager6/Toolkit.js b/www/manager6/Toolkit.js
index 263dea1..ff59a55 100644
--- a/www/manager6/Toolkit.js
+++ b/www/manager6/Toolkit.js
@@ -112,6 +112,39 @@ Ext.override(Ext.form.field.ComboBox, {
     }
 });
 
+// ExtJs 5-6 has an issue with caching
+// see https://www.sencha.com/forum/showthread.php?308989
+Ext.define('PVE.UnderlayPool', {
+    override: 'Ext.dom.UnderlayPool',
+
+    checkOut: function () {
+        var cache = this.cache,
+            len = cache.length,
+            el;
+
+        // do cleanup because some of the objects might have been destroyed
+	while (len--) {
+            if (cache[len].destroyed) {
+                cache.splice(len, 1);
+            }
+        }
+        // end do cleanup
+
+	el = cache.shift();
+
+        if (!el) {
+            el = Ext.Element.create(this.elementConfig);
+            el.setVisibilityMode(2);
+            //<debug>
+            // tell the spec runner to ignore this element when checking if the dom is clean
+	    el.dom.setAttribute('data-sticky', true);
+            //</debug>
+	}
+
+        return el;
+    }
+});
+
 Ext.define('Ext.ux.IFrame', {
     extend: 'Ext.Component',
 
-- 
2.1.4





More information about the pve-devel mailing list