JPEG Thumbnailer

Ingo Klöcker kloecker at
Mon Aug 18 20:12:58 BST 2008

On Monday 18 August 2008, Andre Gemünd wrote:
> Michael Pyne schrieb:
> > Actually it's easier than that:
> >
> > On an opened QFile you can use QFile::handle() to return the file
> > descriptor (i.e. what is passed to write(2)). Using the file
> > descriptior you can use the C stdio fdopen() function to return a
> > FILE* tied to that file descriptor.
> >
> > This way you can still use stdio functions on a file managed by
> > QFile.
> >
> > All that this would really buy you is guaranteeing that the file
> > gets closed, which may not be worth the overhead however if you're
> > simply going to be passing the FILE* to libjpeg.
> >
> > Regards,
> Hi Michael,
> thanks a lot for you explanation. As I said, I'm not very experienced
> with Qt/KDE programming yet, so your input is very appreciated.
> How much overhead are we talking about? We are opening all jpeg files
> of a directory which can be a lot at times, and apply a not-so-costly
> operation, so we should take this into consideration. And you are
> right, I just pass the FILE* to libjpeg and close it after
> jpeg_finish_decompress(), so it doesn't seem very sensible to open it
> twice (QFile and fdopen).

The point of using QFile is that you do not have to take care of the 
file resource yourself. QFile will take care of closing the file. Using 
a class for handling a resource (e.g. QFile for a file, smart pointers 
for objects allocated on the heap, etc.) is always preferable to 
dealing with the resource yourself, because it's so darn easy to leak a 
resource if you do it yourself.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the kde-core-devel mailing list