Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventDispatcher have a BUG! #11476

Open
JasonLion-CN opened this issue Apr 17, 2015 · 1 comment
Open

EventDispatcher have a BUG! #11476

JasonLion-CN opened this issue Apr 17, 2015 · 1 comment

Comments

@JasonLion-CN
Copy link

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)

@walzer walzer added this to the unconfirmed milestone Apr 23, 2015
@voiddog
Copy link

voiddog commented Apr 29, 2016

There is a _priorityDirtyFlagMap in the CCEventDispatcher.cpp, at the end of dispatchEvent(event), it will called updateListeners(event);

In the updateListeners(event), it will remove the listener whitch is unregistered. But the cocos did not set the dity flag to DirtyFlag::SCENE_GRAPH_PRIORITY or DirtyFlag::FIXED_PRIORITY.

To resolve this bug, I add two sentences to the updateListeners(Event *event):

...
iter = sceneGraphPriorityListeners->erase(iter);
// line (1161)
setDirty(l->getListenerID(), DirtyFlag::SCENE_GRAPH_PRIORITY);
...
iter = fixedPriorityListeners->erase(iter);
// line (1183)
setDirty(l->getListenerID(), DirtyFlag::FIXED_PRIORITY);
...

@minggo minggo removed this from the unconfirmed milestone Aug 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants