Open
Description
When EventDispatcher is in working(flag _inDispatch == 1) and removeEventListener is called:
if (_inDispatch == 0)
{
listeners->erase(iter);
CC_SAFE_RELEASE(l);
}
its mean the listener was not be remove from listeners,until updateListeners to be call 。
In the dispatchTouchEvent member functionc:
sortEventListeners() to cause Gt0Index be set: listeners->setGt0Index(index)
then, updateListeners to call and remove listener that not remove before, so that the size of fixedPriorityListeners is change.
so cause the assert to failed.
CCASSERT(listeners->getGt0Index() <= static_cast<ssize_t>(fixedPriorityListeners->size()), "Out of range exception!"); (line:734)
Activity
voiddog commentedon Apr 29, 2016
There is a
_priorityDirtyFlagMap
in theCCEventDispatcher.cpp
, at the end ofdispatchEvent(event)
, it will calledupdateListeners(event);
In the
updateListeners(event)
, it will remove the listener whitch is unregistered. But the cocos did not set the dity flag toDirtyFlag::SCENE_GRAPH_PRIORITY
orDirtyFlag::FIXED_PRIORITY
.To resolve this bug, I add two sentences to the
updateListeners(Event *event)
: