diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2011-11-15 16:39:16 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-15 17:09:35 +0100 |
commit | 202127f860208c21145e05685bc54219e1655dbd (patch) | |
tree | cead403f01d83f93f3c3f4850b38756338d5e418 /tests/auto/gui/qopengl/tst_qopengl.cpp | |
parent | 7b3bb6759bb3ab2c8b976a1710cd0372df00188d (diff) |
Ensure that QOpenGLMultiGroupSharedResources are cleaned up
When a GL context group is destroyed, all multi-group shared
resources associated with the group should be cleaned up.
Otherwise we could get a double deletion in the resource's
destructor, because it still retained a pointer to the
deleted group.
The missing cleanup resulted in a crash when the global
static qt_gl_functions_resource was destroyed, first seen
in the tst_examples autotest in qtdeclarative. It possibly
didn't manifest before because it's event loop-dependent
(the contexts are deleted via deleteLater()).
Change-Id: I6b1e0bfdfbbb2bff8e795f545e680fcdfa094768
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'tests/auto/gui/qopengl/tst_qopengl.cpp')
-rw-r--r-- | tests/auto/gui/qopengl/tst_qopengl.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index 479c1c8e2e..a3e0cf4fba 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -42,6 +42,7 @@ #include <QtGui/private/qopenglcontext_p.h> #include <QtGui/QOpenGLFramebufferObject> +#include <QtGui/QOpenGLFunctions> #include <QtGui/QOpenGLPaintDevice> #include <QtGui/QPainter> #include <QtGui/QScreen> @@ -55,6 +56,7 @@ Q_OBJECT private slots: void sharedResourceCleanup(); + void multiGroupSharedResourceCleanup(); void fboSimpleRendering(); void fboRendering(); void fboHandleNulledAfterContextDestroyed(); @@ -172,6 +174,27 @@ void tst_QOpenGL::sharedResourceCleanup() QCOMPARE(tracker.destructorCalls, 1); } +void tst_QOpenGL::multiGroupSharedResourceCleanup() +{ + QWindow window; + window.setGeometry(0, 0, 10, 10); + window.create(); + + for (int i = 0; i < 10; ++i) { + QOpenGLContext *gl = new QOpenGLContext(); + gl->create(); + gl->makeCurrent(&window); + { + // Cause QOpenGLMultiGroupSharedResource instantiation. + QOpenGLFunctions func(gl); + } + delete gl; + // Cause context group's deleteLater() to be processed. + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + } + // Shouldn't crash when application exits. +} + static bool fuzzyComparePixels(const QRgb testPixel, const QRgb refPixel, const char* file, int line, int x = -1, int y = -1) { static int maxFuzz = 1; |