开罗退出时出现错误消息
我目前正在使用 Cairo 进行一些测试来替换一些现有的 GDI/GDI+ 在 Visual C++ 2010 中编写代码,它似乎工作正常,但我得到 每次关闭应用程序时都会出现错误消息:
“CairoTest.exe 中 0x68e629dc 处的第一次机会异常:0xC0000005: 访问冲突读取位置 0xabababa7"
仅当我在调用 cairo_paint(cr) 时才会发生此错误 应用程序正在运行 - 如果我注释掉这一行,它就会消失。这 到目前为止,我的应用程序中唯一的开罗代码是:
CChildView::CChildView()
{
testsurface = cairo_image_surface_create_from_png("BlackShinyBackground.png");
}
CChildView::~CChildView()
{
cairo_surface_destroy(testsurface);
}
void CChildView::OnPaint()
{
CPaintDC dc(this);
cairo_surface_t *surface = cairo_win32_surface_create(dc.m_hDC);
cairo_t *cr = cairo_create (surface);
cairo_set_source_surface(cr, testsurface, 0, 0);
cairo_paint(cr);
cairo_destroy (cr);
cairo_surface_destroy (surface);
}
任何人都可以指出我做错了什么吗?
就像我说的,代码似乎工作正常,但我不喜欢不管何时看到错误都继续努力。
I'm currently doing some tests using Cairo to replace some existing GDI/GDI+
code in Visual C++ 2010 and it seems to be working fine, but I'm getting
an error message each time I close down my application :
"First-chance exception at 0x68e629dc in CairoTest.exe: 0xC0000005:
Access violation reading location 0xabababa7"
This error only happens if I've called cairo_paint(cr) while the
application is running - if I comment this line out, it disappears. The
only Cairo code in my application so far is :
CChildView::CChildView()
{
testsurface = cairo_image_surface_create_from_png("BlackShinyBackground.png");
}
CChildView::~CChildView()
{
cairo_surface_destroy(testsurface);
}
void CChildView::OnPaint()
{
CPaintDC dc(this);
cairo_surface_t *surface = cairo_win32_surface_create(dc.m_hDC);
cairo_t *cr = cairo_create (surface);
cairo_set_source_surface(cr, testsurface, 0, 0);
cairo_paint(cr);
cairo_destroy (cr);
cairo_surface_destroy (surface);
}
Can anybody point me in the direction of what I'm doing wrong?
Like I said, the code appearsto be working fine, but I don't like just ploughing on regardless when I can see errors.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一次机会异常并不一定意味着什么——它们是 Windows 内存管理的常规部分。基本上,每当您访问虚拟内存中的某些内容(例如,在分页文件上)时,都会创建第一次机会异常。操作系统通过将所需数据分页到物理内存中来处理它,然后您的代码可以继续执行。
如果/当您看到第二次机会异常时,这意味着操作系统没有处理该异常,因此除非您在代码中有一个处理程序,否则很有可能表明一个真正的异常问题。
A first chance exception doesn't necessarily mean much -- they're a routine part of Windows' memory management. Basically, any time you access something that's in virtual memory (e.g., on the paging file) a first chance exception is created. The OS handles it by paging in the required data into physical memory, then your code can continue executing.
If/when you see a second-chance exception, it means the OS didn't handle the exception, so unless you have a handler for it in your code, chances are pretty good that is signals a real problem.