[Interest] QImage, multithreaded app.

Alexander Syvak alexander.svk at gmail.com
Sat Sep 28 00:20:40 CEST 2013


Each object is of type event_analizer. Each such object contains a QImage
buffer (non-static). The event_analizer sends signal
need_screenshot(event_analizer*) where the receiving object uses the
pointer to store the made screenshot. Thuse, no, not on the same QImage
object.
Each thread is storing screenshots in RAM and its folder on HD after some
analysis of each screenshot.


2013/9/27 Thiago Macieira <thiago.macieira at intel.com>

> On sexta-feira, 27 de setembro de 2013 23:13:44, Alexander Syvak wrote:
> >  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
>
> On the *same* QImage?
>
> Like I said, I need to know what each thread is doing. Saving a QImage from
> any thread should be acceptable, provided no other thread is using the same
> QImage.
>
> >
> > 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
>
> --
> 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/20130928/e18be3aa/attachment.html>


More information about the Interest mailing list