在 0x00007FF746DA221B SDL_game.exe 处抛出异常:0xC0000005:访问冲突读取位置 0xFFFFFFFFFFFFFFFF
Exception thrown at 0x00007FF746DA221B SDL_game.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF
我正在尝试调试我的应用程序,但我经常收到此错误,而且我不知道如何修复它。调试的时候发现错误的地方是函数parseObjects。它还从游戏对象工厂调用创建函数,如下所示...
GameObject* GameObjectFactory::create(std::string typeID)
{
std::map<std::string, BaseCreator*>::iterator it = m_creators.find(typeID);
if (it == m_creators.end())
{
std::cout << "could not find type: " << typeID << "\n";
return 0;
}
BaseCreator* pCreator = (*it).second;
return pCreator->createGameObject();}
此后它调用 Creator 对象加载函数成功加载参数,但是当它尝试将对象推回向量时它收到上述错误。
在 0x00007FF746DA221B 处抛出异常 SDL_game.exe:0xC0000005:访问冲突读取位置 0xFFFFFFFFFFFFFFFF。
...
e->Attribute("x", &x);
e->Attribute("y", &y);
e->Attribute("width", &width);
e->Attribute("height", &height);
e->Attribute("numFrames", &numFrames);
e->Attribute("callbackID", &callbackID);
e->Attribute("animSpeed", &animSpeed);
type = e->Attribute("type");
textureID = e->Attribute("textureID");
GameObject* pGameObject = TheGameObjectFactory::Instance()->create(type);
pGameObject->load(new LoaderParams(x, y, width, height, textureID, numFrames, callbackID, animSpeed));
pObjects->push_back(pGameObject); // fails on this line ???
}`
调试器在向量中转到这一行...
bool _Inside(const value_type *_Ptr) const
{ // test if _Ptr points inside vector
return (_Ptr < this->_Mylast() && this->_Myfirst() <= _Ptr);
}
任何帮助和建议将不胜感激...
我认为这可能是因为您的向量 pObjects 未初始化或处于某种损坏状态。
我正在尝试调试我的应用程序,但我经常收到此错误,而且我不知道如何修复它。调试的时候发现错误的地方是函数parseObjects。它还从游戏对象工厂调用创建函数,如下所示...
GameObject* GameObjectFactory::create(std::string typeID)
{
std::map<std::string, BaseCreator*>::iterator it = m_creators.find(typeID);
if (it == m_creators.end())
{
std::cout << "could not find type: " << typeID << "\n";
return 0;
}
BaseCreator* pCreator = (*it).second;
return pCreator->createGameObject();}
此后它调用 Creator 对象加载函数成功加载参数,但是当它尝试将对象推回向量时它收到上述错误。
在 0x00007FF746DA221B 处抛出异常 SDL_game.exe:0xC0000005:访问冲突读取位置 0xFFFFFFFFFFFFFFFF。
...
e->Attribute("x", &x);
e->Attribute("y", &y);
e->Attribute("width", &width);
e->Attribute("height", &height);
e->Attribute("numFrames", &numFrames);
e->Attribute("callbackID", &callbackID);
e->Attribute("animSpeed", &animSpeed);
type = e->Attribute("type");
textureID = e->Attribute("textureID");
GameObject* pGameObject = TheGameObjectFactory::Instance()->create(type);
pGameObject->load(new LoaderParams(x, y, width, height, textureID, numFrames, callbackID, animSpeed));
pObjects->push_back(pGameObject); // fails on this line ???
}`
调试器在向量中转到这一行...
bool _Inside(const value_type *_Ptr) const
{ // test if _Ptr points inside vector
return (_Ptr < this->_Mylast() && this->_Myfirst() <= _Ptr);
}
任何帮助和建议将不胜感激...
我认为这可能是因为您的向量 pObjects 未初始化或处于某种损坏状态。