PDA

View Full Version : [FIXED] [4.2.2.1144] Ext.app.EventDomain dispatches suspended Events



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

Ext 4.2.2.1144

Description:
When suspending an event the EventDomain still dispatches it

Steps to reproduce the problem:

Add Listener in the Controller's control function
Suspend the event that is listened
Fire that event

The result that was expected:

Nothing happens, as the event is suspended and so not allowed to fire

The result that occurs instead:

The function defined in the Controller's control selector is executed

Test Case:

e = Ext.create('Ext.app.EventDomain', {
type: 'test'
}),
e.idProperty = 'anything';
testFnCalled = 0,
testFn = function() {
testFnCalled++;
};

e.monitor(Ext.ClassManager.get('Ext.Component'));

e.listen({
'*': {
dummy: testFn
}
}, {
// dummy controller
id: 'test'
});

var tesFnCalledBefore = testFnCalled;
c.fireEvent('dummy');

console.log(testFnCalled - tesFnCalledBefore) // 1 - The event domain fired the test function once


c.on('dummy', Ext.emptyFn); // make sure event is properly created (see text below HELPFUL INFORMATION)
c.suspendEvent('dummy');

var tesFnCalledBefore = testFnCalled;
c.fireEvent('dummy');

console.log(testFnCalled - tesFnCalledBefore) // 1 - The event domain fired the test function once but shouldnt as the event is suspended


HELPFUL INFORMATION
Possible fix:


Ext.define('Perbility.fix.app.EventDomain', {
override: 'Ext.app.EventDomain',

dispatch: function(target, ev, args) {
var event = target.events && target.events[ev];
if (event && event.suspended) {
return true;
}

return this.callOverridden(arguments);
}

});


You most likely also want to put this fix here in place too: [4.2.2.1144] Ext.util.Observable#suspendEvent does not initialize Event (http://www.sencha.com/forum/showthread.php?273269-4.2.2.1144-Ext.util.Observable-suspendEvent-does-not-initialize-Event&p=1001444)
With the other fix in place you do not need to initialize your event manually when suspending it (like done in the example above "c.on('dummy', Ext.emptyFn)").

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