调试断言失败。空指针

时间:2012-09-11 10:25:13

标签: c++

当我尝试执行我的应用程序的.exe时遇到此问题 “调试断言失败!,表达式无效空指针”

经过一段谷歌搜索后,我想我知道问题在哪里,但不知道如何解决。

以下是相关的代码。

size_t idx;
// create the initial texture
atlases.push_back(new TextureAtlas( image_names.size()));
// load the texture
for (idx = 0; idx < image_names.size(); ++idx) {
//load the image
TextureInformation *ti = new TextureInformation (idx, folder_location_str, image_names[idx]);

在初始化ti的行执行代码期间,声明本地选项卡中的值(在ms visual c ++ 2008中)如下所示。

ti TextureInformation *
idx CXX0030: Error: expression cannot be evaluated
image_path {npos=4294967295 _Bx={...} _Mysize=??? ...} std::basic_string<char,std::char_traits<char>,std::allocator<char> >
image_name {npos=4294967295 _Bx={...} _Mysize=??? ...} std::basic_string<char,std::char_traits<char>,std::allocator<char> >
image CXX0017: Error: symbol "" not found 

出于某种原因:idx和image在这里显示错误,这只发生在for循环的第一次迭代中。以下是第二次迭代期间ti的内容

idx 0 unsigned int
+ image_path ".....Related\PNG\" std::basic_string<char,std::char_traits<char>,std::allocator<char> >
+ image_name "basn0g01.png" std::basic_string<char,std::char_traits<char>,std::allocator<char> >
+ image 0x00812830 {m_info={...} m_pixbuf={...} } png::image<png::basic_rgba_pixel<unsigned char> > *

这就是我的TextualInformation看起来

的方式
class TextureInformation
{
public:
TextureInformation(size_t index, std::string path, std::string name)
: idx(index), image_path(path), image_name(name)
{
image = new png::image<png::rgba_pixel>(image_path + image_name,
png::convert_color_space<png::rgba_pixel>());
}
~TextureInformation(void)
{
delete image;
}
....
....
private:
size_t idx;
std::string image_path;
std::string image_name;
png::image<png::rgba_pixel>* image;
};

如果需要其他详细信息,请告诉我。感谢

0 个答案:

没有答案