[Qt-interest] QtConcurrent::run results in random crashes

Anders Bakken anders.bakken at myriadgroup.com
Fri Jul 30 19:24:22 CEST 2010


On Wed, Jul 28, 2010 at 05:44:07AM +0100, Mandeep Sandhu wrote:
> > Thanks for that, I really didn't know that using QPixmap outside the
> > Main/GUI thread is a problem. I will do the scaling of my thumbnails
>
> I had a similar problem (of app crashing when trying to create a
> QPixmap in a console app).
>
> You will  need an instance of "QApplication" for using QPixmaps since
> it initializes the underlying OS's graphics subsystem, which will be
> there in your main GUI thread. Once that is done, I "think" it should
> be safe to use QPixmaps in another thread as well.

This is from qpixmap.cpp:

static bool qt_pixmap_thread_test()
{
    if (!qApp) {
        qFatal("QPixmap: Must construct a QApplication before a QPaintDevice");
        return false;
    }
#ifndef Q_WS_WIN
    if (qApp->thread() != QThread::currentThread()) {
        qWarning("QPixmap: It is not safe to use pixmaps outside the GUI thread");
        return false;
    }
#endif
    return true;
}

>
> If you're NOT going to do any pixel manipulation of your images and
> instead only want to paint them (after scaling) then I guess it's
> better to use QPixmaps than QImage.
>
> HTH,
> -mandeep

regards

--
Anders Bakken

This message, including attachments, is intended solely for the addressee indicated in this message and is strictly confidential or otherwise privileged. If you are not the intended recipient (or responsible for delivery of the message to such person) : - (1) please immediately (i) notify the sender by reply email and (ii) delete this message and attachments, - (2) any use, copy or dissemination of this transmission is strictly prohibited. If you or your employer does not consent to Internet email messages of this kind, please advise Myriad Group AG by reply e-mail immediately. Opinions, conclusions and other information expressed in this message are not given or endorsed by Myriad Group AG unless otherwise indicated by an authorized representative independent of this message.




More information about the Qt-interest-old mailing list