vector iterator not incrementable
wbbtcool opened this issue · 1 comments
wbbtcool commented
cocos2x : 3.14.1
platform:win32
IDE: vs2015
My English is not very good. In win32 , i have encountered a problem in which the animation can not be played. But iOS and Android will not happen.
Debug Assertion Failed!
Program: C:\Windows\SYSTEM32\MSVCP140D.dll
File: f:\microsoft visual studio 14.0\vc\include\vector
Line: 101
Expression: vector iterator not incrementable
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
I modified the official demo.
my code:
_armatureDisplay = _factory.buildArmatureDisplay("DragonBoy");
const auto center = cocos2d::Director::getInstance()->getVisibleSize();
_armatureDisplay->setPosition(center.width * 0.5f, center.height * 0.5f);
_armatureDisplay->setScale(_armatureScale);
this->addChild(_armatureDisplay);
_armatureDisplay->getAnimation().play("stand");
_armatureDisplay->getEventDispatcher()->setEnabled(true);
_armatureDisplay->getEventDispatcher()->addCustomEventListener(EventObject::COMPLETE, [=] (EventCustom *event) {
const auto eventObject = (dragonBones::EventObject*)event->getUserData();
eventObject->armature->getAnimation().play("walk");
});
The program will stop here.
Armature.h
if (!_events.empty())
{
for (const auto event : _events) //debug stop here
{
if (EventObject::_soundEventManager && event->type == EventObject::SOUND_EVENT)
{
EventObject::_soundEventManager->_dispatchEvent(event);
}
else
{
_display->_dispatchEvent(event);
}
event->returnToPool();
}
_events.clear();
}
I don't know why it happened .
Help. Thanks!
wbbtcool commented
......I found.
for (const auto event : _events)
modify:
for (unsigned int i = 0; i < _events.size(); i++)
{
EventObject* event = _events[i];
......
}