Subject: Re: [boost] gil::io "non-review" (was: [gil] Can not open test.jpg)
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2010-03-24 18:57:43
John Bytheway wrote:
> On 24/03/10 20:13, Christian Henning wrote:
>> I have updated and uploaded the code. If someone could have a look I
>> would really appreciate it.
Well, have a look at read_rows(). Say one of the jpeg_read_scalines()
calls fails and calls the error handler. I think that:
- The dtor for buffer will not be called because you have longjump()d
out of its scope.
- jpeg_destroy_decompress() will be called twice, once in raise_error()
and again in ~jpeg_destroy_decompress() when the exception propagates up.
>> Does someone has an idea how to deal with multi-threaded scenarios?
> The jpeg_compress_struct (and its friends) has a void* client_data. If
> you make the jmp_buf a local variable and pass it through to the error
> handler using that field then I think everything should be OK?
Just put 'this' in client_data and put the jmpbuf in your object.
(As I think I suggested before, to me personally it would be more
useful to have a set of wrappers for these libraries that only deal
with these C++-ification issues, rather than the full gil integration
that you're offering. For example the whole issue with memory usage
where you're saying that "memory is cheap, everyone has gigabytes these
days" just doesn't apply to the digital photo frames and mobile phones
that I'm dealing with. So in order to get anything useful from this, I
would love to decouple this 'library wrapping' from the gil aspect.)