From: Gunnar Sletta Date: Wed, 24 Aug 2011 04:57:27 +0000 (+0200) Subject: Warn when grab() is called outside the GUI thread. X-Git-Tag: qt-v5.0.0-alpha1~1697^2~58 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=86680a46021d89e1ff77275e0427c4b20a19a270;p=profile%2Fivi%2Fqtdeclarative.git Warn when grab() is called outside the GUI thread. Change-Id: I24eb1c5c884e80017d8a1123120538553e825064 Reviewed-on: http://codereview.qt.nokia.com/3443 Reviewed-by: Qt Sanity Bot Reviewed-by: Sarah Jane Smith --- diff --git a/src/declarative/items/qsgcanvas.cpp b/src/declarative/items/qsgcanvas.cpp index 1caee4f..33d661e 100644 --- a/src/declarative/items/qsgcanvas.cpp +++ b/src/declarative/items/qsgcanvas.cpp @@ -1843,6 +1843,8 @@ QGLFramebufferObject *QSGCanvas::renderTarget() const This function might not work if the view is not visible. \warning Calling this function will cause performance problems. + + \warning This function can only be called from the GUI thread. */ QImage QSGCanvas::grabFrameBuffer() { @@ -2193,6 +2195,11 @@ QImage QSGCanvasRenderThread::grab() if (!isRunning()) return QImage(); + if (QThread::currentThread() != qApp->thread()) { + qWarning("QSGCanvas::grabFrameBuffer: can only be called from the GUI thread"); + return QImage(); + } + #ifdef THREAD_DEBUG printf("GUI: doing a pixelwise grab..\n"); #endif