C++ 地图::插入正在中断

C++ 地图::插入正在中断,c++,stl,map,C++,Stl,Map,我的map::insert方法正在崩溃,没有给我很多有用的信息 typedef map<wstring, int> IndexLookupMap; static IndexLookupMap indexLookup; static vector<LPDIRECT3DTEXTURE9> textures; extern "C" void EXPORT_API LoadTexture(const wchar_t* file, int* index, unsigned cha

我的map::insert方法正在崩溃,没有给我很多有用的信息

typedef map<wstring, int> IndexLookupMap;
static IndexLookupMap indexLookup;
static vector<LPDIRECT3DTEXTURE9> textures;

extern "C" void EXPORT_API LoadTexture(const wchar_t* file, int* index, unsigned char* data) {

    wstring key(file);

    if(indexLookup.size() > 0)
    {
        IndexLookupMap::iterator it = indexLookup.find(key);

        if(it == indexLookup.end())
        {
            //not found, load it
            LPDIRECT3DTEXTURE9 pTexture;
            D3DXCreateTextureFromFile(g_D3D9Device, file, &pTexture);
            textures.push_back(pTexture);
            *index = textures.size() - 1;
            D3DLOCKED_RECT locked;
            pTexture->LockRect(0, &locked, NULL, 0);

            data = reinterpret_cast<unsigned char*>(locked.pBits);

            pTexture->UnlockRect(0);

            indexLookup.insert(IndexLookupMap::value_type(key, *index));
        }
        else
        {
            //found, get it
            *index = it->second;
            textures.at(*index);
        }
    }
    else
    {
        //not found, load it
        LPDIRECT3DTEXTURE9 pTexture;
        D3DXCreateTextureFromFile(g_D3D9Device, file, &pTexture);
        textures.push_back(pTexture);
        *index = textures.size() - 1;
        D3DLOCKED_RECT locked;
        pTexture->LockRect(0, &locked, NULL, 0);

        data = reinterpret_cast<unsigned char*>(locked.pBits);

        pTexture->UnlockRect(0);

        indexLookup.insert(IndexLookupMap::value_type(key, *index)); //breaks here
    }
}
实际中断发生在xtree中:

_Nodeptr _Trynode = _Root();

根据提供的最少信息,我怀疑在构建
贴图之前调用了
LoadTexture
,导致它处于无效状态。

什么是“它正在破坏”意思?我正在Unity3D内部作为插件运行它,中断意味着:程序崩溃/退出。@StormKiernan:请先进行一些调试以隔离问题,然后再发布代码。我已经做了。我给了你确切的线路。如果我有更多的信息,我会告诉你的。它并没有打断我的任何代码行,而是打断了STL代码的内部,并且没有提供任何有用的错误?运行时错误?编译时错误?具体是什么错误?您调试它时遇到问题,因为您没有获得“很多有用的信息”,但您给我们的信息更少。
_Nodeptr _Trynode = _Root();