PDA

View Full Version : [FIXED] [4.2.2.1144] Ext.util.Observable#suspendEvent does not initialize Event



GustavR
7 Oct 2013, 4:50 AM
REQUIRED INFORMATION
Ext version tested:

Ext 4.2.2.1144

Description:
When suspending an event we expect the event to be suspended but if the event was not yet initialized it is not suspnded

Steps to reproduce the problem:

Suspend event
Listen to the event
Fire the event

The result that was expected:

Nothing, because the event is suspended

The result that occurs instead:

The listener is called

Test Case:

https://fiddle.sencha.com/#fiddle/rj



c = Ext.create('Ext.Component');
console.log(c.events['show']) // true - At beginning the event is just an boolean

c.suspendEvent('show');
console.log(c.events['show'] instanceof Ext.util.Event) // false - The event is no instance of Ext.util.Event so it surely is not suspended


HELPFUL INFORMATION
Possible fix:


Ext.define('Perbility.fix.util.Observable', {
override: 'Ext.util.Observable',

suspendEvent: function(eventName) {
var me = this,
len = arguments.length,
i, event;

for (i = 0; i < len; i++) {
event = me.events[arguments[i]];

// If it exists, and is an Event object (not still a boolean placeholder), suspend it
if (event) {
if (!event.isEvent) {
me.events[eventName] = event = Ext.create('Ext.util.Event', me, eventName);
}
event.suspend();
}
}
}

});


Without this fix my other fix here [4.2.2.1144] Ext.app.EventDomain dispatches suspended Events (http://www.sencha.com/forum/showthread.php?273267-4.2.2.1144-Ext.app.EventDomain-dispatches-suspended-Events&p=1001441) will most likely not work, because the event you suspend may be not initialized. A dirty workaround would be to add a listener to the event you want to suspend and remove it again immediately and afterwards you can suspend the event.

If you put both fixes in place you can finally stop the controller listening to all the suspended events. :)

Gary Schlosberg
7 Oct 2013, 3:24 PM
Thanks for the report! We have opened a bug in our bug tracker.

CptS
3 Feb 2014, 5:05 AM
I just encountered this error as well. Is there a release date for 4.2.3?

Gary Schlosberg
5 Feb 2014, 9:13 AM
No release date scheduled yet.