我的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
}
}
它正在打破:
indexLookup.insert(IndexLookupMap::value_type(key, *index));
实际中断发生在xtree:
_Nodeptr _Trynode = _Root();
答案 0 :(得分:3)
根据提供的最少信息,我怀疑在构建LoadTexture
之前调用了map
,导致它处于无效状态。