开罗退出时出现错误消息

发布于 2024-09-16 21:41:51 字数 861 浏览 3 评论 0原文

我目前正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傾旎 2024-09-23 21:41:51

第一次机会异常并不一定意味着什么——它们是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文