Warn when grab() is called outside the GUI thread.
authorGunnar Sletta <gunnar.sletta@nokia.com>
Wed, 24 Aug 2011 04:57:27 +0000 (06:57 +0200)
committerGunnar Sletta <gunnar.sletta@nokia.com>
Wed, 24 Aug 2011 06:00:58 +0000 (08:00 +0200)
Change-Id: I24eb1c5c884e80017d8a1123120538553e825064
Reviewed-on: http://codereview.qt.nokia.com/3443
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Sarah Jane Smith <sarah.j.smith@nokia.com>
src/declarative/items/qsgcanvas.cpp

index 1caee4f..33d661e 100644 (file)
@@ -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