aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quickwidgets
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2016-06-22 12:17:15 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2016-06-29 08:23:24 +0000
commita174ed2a996bf6311e849c8d8f31bbe307c6838b (patch)
tree8ff2bfe9a83ac06cd79fd44187a5dab1efaba235 /tests/auto/quickwidgets
parent285007f9687ef8aca6faed89f0c56696c2612548 (diff)
Handle AA_ShareOpenGLContexts consistently in QQuickWidget
QOpenGLWidget has offered a lot more fine-grained control over the lifetime of the OpenGL context it uses for rendering. In practice QQuickWidget also requires at least a part of this. To unify the behavior when it comes to reparenting to a different top-level window, add the bail out condition for AA_ShareOpenGLContexts to QQuickWidget as well. [ChangeLog][QtQuick][Important Behavior Changes] QQuickWidget now behaves identically to QOpenGLWidget when it comes to handling window changes when reparenting the widget into a hierarchy belonging to another top-level widget. Previously the OpenGL context always got destroyed and recreated in order to ensure texture resource sharing with the new top-level widget. From now on this is only true when when AA_ShareOpenGLContexts it not set. Task-number: QTBUG-54133 Change-Id: Ifda0db76fdf71dae1b9606fb5d59cee6edc2f5a4 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'tests/auto/quickwidgets')
-rw-r--r--tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
index 09359060f6..7676bd6c31 100644
--- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
+++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp
@@ -34,6 +34,7 @@
#include <QtQuick/qquickitem.h>
#include "../../shared/util.h"
#include <QtGui/QWindow>
+#include <QtGui/QImage>
#include <QtCore/QDebug>
#include <QtQml/qqmlengine.h>
@@ -55,6 +56,7 @@ private slots:
void readback();
void renderingSignals();
void grabBeforeShow();
+ void reparentToNewWindow();
};
@@ -301,6 +303,27 @@ void tst_qquickwidget::grabBeforeShow()
QVERIFY(!widget.grab().isNull());
}
+void tst_qquickwidget::reparentToNewWindow()
+{
+ QWidget window1;
+ QWidget window2;
+
+ QQuickWidget *qqw = new QQuickWidget(&window1);
+ qqw->setSource(testFileUrl("rectangle.qml"));
+ window1.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window1, 5000));
+ window2.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window2, 5000));
+
+ QSignalSpy afterRenderingSpy(qqw->quickWindow(), &QQuickWindow::afterRendering);
+ qqw->setParent(&window2);
+ qqw->show();
+ QTRY_VERIFY(afterRenderingSpy.size() > 0);
+
+ QImage img = qqw->grabFramebuffer();
+ QCOMPARE(img.pixel(5, 5), qRgb(255, 0, 0));
+}
+
QTEST_MAIN(tst_qquickwidget)
#include "tst_qquickwidget.moc"