PDA

View Full Version : [IE7] - can't remove sprites



LesJ
29 Dec 2011, 2:48 PM
I have a weird problem with a drawing application that I'm trying to upgrade to 4.1 Beta...

This is a floor planning app. The way it works is quite simple. I select a building and floor plan is drawn. I select another building and the previous floor plan is removed and a new plan is drawn.

This works fine in 4.0.6 (IE7 and newer browsers). However, after switching to 4.1 Beta, after I select the 4th building, the previous floor plan is not removed and a new plan is drawn on top of the old one.

This happens only in IE7, Firefox is fine. When I switch back to 4.0.6, IE7 works fine as well.

I don't see any error messages. Any idea what could be happening?

It's not easy to come up with a test case :)

LesJ
30 Dec 2011, 7:39 AM
I managed to create a small test case recreating the problem.

Click the 'Add Green Sprite' button and then click the 'Add Blue Sprite' button.

Alternate button clicks... eventually (under 20 clicks) you will see both sprites, .i.e. the removeAll() call fails to remove the sprites.

NOW here is the interesting point... If I remove the sprite ids "blue" and "green", then the sprites are removed correctly. Use IE7 for testing.


var draw = Ext.create('Ext.draw.Component', {
viewBox: false,
width: 400,
height: 400,
renderTo: Ext.getBody()
});

Ext.create('Ext.Button', {
text : 'Add Green Sprite',
renderTo: Ext.getBody(),
handler : function() {
draw.surface.removeAll(true);
draw.surface.add({
"type": "path",
"id": "green",
"path": "M 66.0,198.0 L 64.0,198.0 L 64.0,193.0 L 66.0,193.0Z",
"stroke": "#000",
"stroke-width": 1,
"fill": "green"
}).show(true);
}
});

Ext.create('Ext.Button', {
text : 'Add Blue Sprite',
renderTo: Ext.getBody(),
handler : function() {
draw.surface.removeAll(true);
draw.surface.add({
"type": "path",
"id": "blue",
"path": "M 355.0,194.0 L 355.0,187.0 L 363.0,187.0 L 363.0,194.0Z",
"stroke": "#000",
"stroke-width": 1,
"fill": "blue"
}).show(true);
}
});

LesJ
31 Dec 2011, 3:28 AM
There's a simple workaround - don't reuse sprite ids. Let's say you had a sprite with an id "fixture_1" and then the sprite is removed, don't add a new sprite with the same id even though the old one was destroyed. It appears that Ext is caching the removed sprites (?).

gauravjaincse
1 Mar 2013, 1:00 PM
Hi Less,

Thanx for your explaination. It is very helpful to understand my problem. In my case i am creating sprite id logically. On the basis of that logic i am retrieving my sprite from sprite group. Is there any way by which i can stop ext caching functionality.