0
votes

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.

1

1 Answers

1
votes

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.