PDA

View Full Version : [OPEN] [FIXED-226][3.0r5286] "tabchange" event fired while TabPanel is destroyed



canxss
6 Sep 2009, 4:00 PM
Hi,

I'm using the latest 3.x from SVN and I realized that while a TabPanel is getting destroyed, if it has a listener on "tabchange" event, it gets called.

This behavior started problems on my perfectly working forms. Doesn't listeners should be removed while destroying the components? I debugged the code and checked the differences between the last working ext-all-debug.js and if I'm not wrong this is happening because of changing the place of this line:

Ext.Panel.superclass.beforeDestroy.call(this);

This is moved from the end to the beginning of beforeDestroy method of Panel. During destroy of TabPanel, Panel.beforeDestroy gets called and it calls Container.beforeDestroy. And container starts to remove items with doRemove. At this time TabPanels.onRemove method gets called and on the way it changes the activeTab.

I couldn't figure out what is the problem but apparently while destroying tabs from TabPanel, tabchange event shouldn't be fired.

Here is the simple code snippet to see that tabchange event gets fired while closing the form:


Ext.onReady(function() {

Ext.QuickTips.init();

var win = new Ext.Window({
width: 650,
height: 300,
layout: 'fit',
items: {
xtype: 'tabpanel',
border: false,
plain: true,
deferredRender: false,
layoutOnTabChange: true,
activeTab: 0,
defaults: {
bodyStyle: 'padding:5px 3px 5px 3px'
},
items: [{
title: 'Tab1'
}, {
title: 'Tab2'
}],
listeners: {
'tabchange': function(comp, tab) {
console.log('onTabChange', comp, tab);
},
scope: this
}
}
});
win.show();
});


Thanks in advance

jsakalos
6 Sep 2009, 4:39 PM
Hmm, I cannot reproduce it FF-3.5.2, FB-1.4.2@Linux_x86_64. What I've done:

1. Wrapped your code in html
2. Run against r5286
3. Left Tab 1 selected and closed the window. Result: no event
4. Activated Tab 2 and closed the window. Result: no event

No idea what's going on here other than you may have some older version in cache.

canxss
6 Sep 2009, 5:36 PM
Really! I wasn't expecting that. I'm also using FF 3.5.2, cache is disabled and I've again replaced my ext-all-debug from SVN in case I've missed something.

But nothing? What am I missing?

jsakalos
7 Sep 2009, 12:54 AM
I've re-tested it and I still cannot reproduce it. Here is my html:


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="ext3/resources/css/ext-all.css">
<script type="text/javascript" src="ext3/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext3/ext-all-debug.js"></script>
<title id="page-title">Title</title>
<script type="text/javascript">
Ext.BLANK_IMAGE_URL = 'ext3/resources/images/default/s.gif';
Ext.onReady(function() {
Ext.QuickTips.init();
var win = new Ext.Window({
width: 650,
height: 300,
layout: 'fit',
items: {
xtype: 'tabpanel',
border: false,
plain: true,
deferredRender: false,
layoutOnTabChange: true,
activeTab: 0,
defaults: {
bodyStyle: 'padding:5px 3px 5px 3px'
},
items: [{
title: 'Tab1'
}, {
title: 'Tab2'
}],
listeners: {
'tabchange': function(comp, tab) {
console.log('onTabChange', comp, tab);
},
scope: this
}
}
});
win.show();

});
</script>
</head>
<body>
</body>
</html>

canxss
7 Sep 2009, 3:26 AM
Thanks for retrying Saki. But I'm really gonna loose my mind :) My html is same as yours. I'm sure it's not about the cache. I also debugged it in IE8 through Visual Studio and I get the same problem. I even made a new clean check-out of all Ext JS 3.x project in case my builder file is corrupt, but unfortunately still no difference!

I need to fix this problem immediately but nothing more comes to my mind about what can be the problem.

jsakalos
7 Sep 2009, 4:11 AM
Anyone else that could test it? Just in the case that I have some problem somewhere...

jsakalos
7 Sep 2009, 4:31 AM
Sorry for misleading you - it was my problem. I've overlooked that JSBuilder2 unconditionally outputs built Ext into ext-3.0+ subdirectory.

So, I can confirm it, the unwanted event does fire. Should I move this thread to bugs?

canxss
7 Sep 2009, 6:07 AM
?t's OK Saki, it happens. ?'m glad that you've replicated the problem. Please move this thread to bugs.

Condor
7 Sep 2009, 6:38 AM
You could solve this by adding:

Ext.override(Ext.TabPanel, {
beforeDestroy : function() {
if(this.items){
this.items.each(function(item){
if(item && item.tabEl){
Ext.get(item.tabEl).removeAllListeners();
item.tabEl = null;
}
}, this);
}
if(this.strip){
this.strip.removeAllListeners();
}
this.activeTab = null;
Ext.TabPanel.superclass.beforeDestroy.apply(this);
}
});

@jsakalos: Were you suffering from this problem (http://www.extjs.com/forum/showthread.php?t=79430)?

jsakalos
7 Sep 2009, 6:45 AM
@condor, not exactly. I just assumed that, as for Ext 2.x, files are placed in the same directory as svn root. I had one old ext-all-debug.js file in the svn root so pages worked. However, the newly built ext-all-debug.js from ext-3.0+ directory was not used.

canxss
7 Sep 2009, 1:07 PM
Thanks Condor,

Your fix solved the problem. But it will also be fixed in source, right?

jsakalos
7 Sep 2009, 1:34 PM
Yes, Bugs forum is scanned by devel team and they fix bugs.

evant
7 Sep 2009, 5:56 PM
Fix applied to svn in rev #5295 for patch release 3.1.

Targetting 3.1 because the related changes aren't in the patch branch.