Forums » C++ Framework » CCTouchDispatcher::removeDelegate() may prevent delegates from being added correctly »
| Andre Rudlaff | CCTouchDispatcher::removeDelegate() may prevent delegates from being added correctly | ||
|---|---|---|---|
|
Added by Andre Rudlaff about 1 year ago
We had a strange bug today, that sometimes a touch delegate wasn't added to the touch dispatcher correctly. It turns out, the reason for the issue was the delayed removal of touch delegates. When the remove is requested while the touch dispatcher is locked. The issue is not really reproducable, so I try to explain what happens: There is another object (say obj2) which has been added to the touch dispatcher. The user clicks on obj2. Within the onClick() method the following happens: m_pHandlersToRemove now contains two objects (obj1 and obj2). Still in the touch callback a new button is added (lets call it obj3) I must admit that the initial error is within the client code (obj1 is removed from the dispatcher, but never added). But I think this situation should be handled by the framework. The same issue may apply with the m_pHandlersToAdd. Probably it is never triggered there as the object isn't deleted before it is really added to the dispatcher. |
||
| James Chen | RE: CCTouchDispatcher::removeDelegate() may prevent delegates from being added correctly | ||
|
Added by James Chen about 1 year ago
Hello, Andre Rudlaff, |
||
| Andre Rudlaff | RE: CCTouchDispatcher::removeDelegate() may prevent delegates from being added correctly | ||
|
Added by Andre Rudlaff about 1 year ago
Hi, should be easy to change the HelloWorld example for reproducing the issue. |
||
| Andre Rudlaff | RE: CCTouchDispatcher::removeDelegate() may prevent delegates from being added correctly | ||
|
Added by Andre Rudlaff about 1 year ago
Attached is a modified HelloWorld project, which triggered the issue whenever I click on the screen. This is the sample output for when the bug occurs: // Click into the Window // Touch Ended for obj1 will trigger switchButtons(), which will remove the added buttons and create new ones HelloWorld.tar.gz (7 kB) |
(1-3/3)