2016-04-24 171 views
0

我想调试我的应用程序,我不断收到此错误,我不知道如何解决它。在调试过程中,我发现错误的地方在于函数parseObjects。它还调用创建游戏对象工厂是如下功能...异常抛出0x00007FF746DA221B SDL_game.exe:0xC0000005:访问冲突读取位置0xFFFFFFFFFFFFFFFF

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();} 

这一点,调用一个造物主对象后,成功地加载参数加载功能,但是,当它试图将对象推回到向量中,它会收到上述错误。

异常抛出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); }

任何帮助和建议将不胜感激...

回答

0

我认为这可能发生,因为你的载体pObjects将不会被初始化或者某种损坏的状态。

相关问题