[Interest] QImage, multithreaded app.
Alexander Syvak
alexander.svk at gmail.com
Fri Sep 27 22:13:44 CEST 2013
This is the code of the function saving screenshots. This code is used in
threads analizing screenshots.
Debugging the app. when one thread has been paused inside QImage save
method and other thread wake up invoking the lines below
QFile screenshot_iodev(mk_screenshot_path(screenshot_idx++));
return screenshot.save( &screenshot_iodev, format_raw_ptr );
where QImage::save returns false failing here
bool QImageWriter::canWrite() const
{
if (d->device && !d->handler && (d->handler =
createWriteHandlerHelper(d->device, d->format)) == 0) {
d->imageWriterError = QImageWriter::UnsupportedFormatError;
d->errorString = QT_TRANSLATE_NOOP(QImageWriter,
QLatin1String("Unsupported
image format"));
return false;
}
2013/9/27 Thiago Macieira <thiago.macieira at intel.com>
> On sexta-feira, 27 de setembro de 2013 16:12:37, Alexander Syvak wrote:
> > Hello,
> >
> > the method save_screenshot() is used to save a QImage object using
> > bool QImage::save ( const
> > QString<http://doc.crossplatform.ru/qt/4.6.x/qstring.html>&
> > *fileName*, const char * *format* = 0, int *quality* = -1 ) const
> >
> > Howver, it appears that QImage is working with one I/O device and returns
> > false if it's busy, i.e. a thread paused at a moment of executing the
> save
> > method.
>
> Any thread? What is this other thread doing? Also, threads don't pause
> except
> if you're using the debugger.
>
> It's far more likely that your mistake can be found in what this other
> thread
> is doing.
>
> >
> > Is it better to use
> > bool QImage::save (
> > QIODevice<http://doc.crossplatform.ru/qt/4.6.x/qiodevice.html>*
> > *device*, const char * *format* = 0, int *quality* = -1 ) const
> >
> > method instead with its own I/O device for each thread or
> >
> > to create QMutexLocker in the save_screenshot() method?
>
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
> Software Architect - Intel Open Source Technology Center
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130927/8592ff68/attachment.html>
More information about the Interest
mailing list