Make it possible to grab() a window after it has been hidden.
authorGunnar Sletta <gunnar.sletta@jollamobile.com>
Fri, 22 May 2015 06:47:34 +0000 (08:47 +0200)
committerGunnar Sletta <gunnar@sletta.org>
Fri, 22 May 2015 08:45:59 +0000 (08:45 +0000)
Windows render loop already had this capability.

Change-Id: I9391e218568cb6951f9f25d74e732aa5ddf9b5bc
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
src/quick/items/qquickwindow.cpp
src/quick/scenegraph/qsgthreadedrenderloop.cpp

index 664e0f791c560a0035fdaf33242429a48778676e..47c7a288344e68e84b05329e82eab5a4ca5d9b92 100644 (file)
@@ -3303,12 +3303,7 @@ QOpenGLFramebufferObject *QQuickWindow::renderTarget() const
 QImage QQuickWindow::grabWindow()
 {
     Q_D(QQuickWindow);
-    if (!isVisible()) {
-
-        if (d->context->openglContext()) {
-            qWarning("QQuickWindow::grabWindow: scene graph already in use");
-            return QImage();
-        }
+    if (!isVisible() && !d->context->openglContext()) {
 
         if (!handle() || !size().isValid()) {
             qWarning("QQuickWindow::grabWindow: window must be created and have a valid size");
index 417a8e64682b56990241a58f276fa56e2331316e..95a0d0f02afa60e57d42c3f65e964bb3753644c0 100644 (file)
@@ -406,20 +406,21 @@ bool QSGRenderThread::event(QEvent *e)
     case WM_Grab: {
         qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "WM_Grab";
         WMGrabEvent *ce = static_cast<WMGrabEvent *>(e);
-        Q_ASSERT(ce->window == window);
+        Q_ASSERT(ce->window);
+        Q_ASSERT(ce->window == window || !window);
         mutex.lock();
-        if (window) {
-            gl->makeCurrent(window);
+        if (ce->window) {
+            gl->makeCurrent(ce->window);
 
             qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- sync scene graph";
-            QQuickWindowPrivate *d = QQuickWindowPrivate::get(window);
+            QQuickWindowPrivate *d = QQuickWindowPrivate::get(ce->window);
             d->syncSceneGraph();
 
             qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- rendering scene graph";
-            QQuickWindowPrivate::get(window)->renderSceneGraph(windowSize);
+            QQuickWindowPrivate::get(ce->window)->renderSceneGraph(ce->window->size());
 
             qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- grabbing result";
-            *ce->image = qt_gl_read_framebuffer(windowSize * window->effectiveDevicePixelRatio(), false, false);
+            *ce->image = qt_gl_read_framebuffer(windowSize * ce->window->effectiveDevicePixelRatio(), false, false);
         }
         qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- waking gui to handle result";
         waitCondition.wakeOne();