summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/qopengl
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2011-11-17 16:06:27 +0100
committerQt by Nokia <qt-info@nokia.com>2011-11-17 17:40:06 +0100
commit44b6bb3560b24ca665140b071a3d11d63ad14c5d (patch)
treeae4264c761364e5df02138d6181d674e221ba482 /tests/auto/gui/qopengl
parent1b681bbd0fd4677236a492ebc29146c4ca24c508 (diff)
Call invalidateResource() on QOpenGLMultiGroupSharedResource-owned resources
Commit 202127f860208c21145e05685bc54219e1655dbd ensured that QOpenGLMultiGroupSharedResource-owned resources are deleted, but it was missing a call to invalidateResource(). Change-Id: I166ce8a7298772408081331fe1a91bd2cd88aebb Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'tests/auto/gui/qopengl')
-rw-r--r--tests/auto/gui/qopengl/tst_qopengl.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp
index a3e0cf4fba..aa3e70a047 100644
--- a/tests/auto/gui/qopengl/tst_qopengl.cpp
+++ b/tests/auto/gui/qopengl/tst_qopengl.cpp
@@ -57,6 +57,7 @@ Q_OBJECT
private slots:
void sharedResourceCleanup();
void multiGroupSharedResourceCleanup();
+ void multiGroupSharedResourceCleanupCustom();
void fboSimpleRendering();
void fboRendering();
void fboHandleNulledAfterContextDestroyed();
@@ -91,22 +92,32 @@ struct SharedResource : public QOpenGLSharedResource
{
}
+ SharedResource(QOpenGLContext *ctx)
+ : QOpenGLSharedResource(ctx->shareGroup())
+ , resource(1)
+ , tracker(0)
+ {
+ }
+
~SharedResource()
{
- tracker->destructorCalls++;
+ if (tracker)
+ tracker->destructorCalls++;
}
void invalidateResource()
{
resource = 0;
- tracker->invalidateResourceCalls++;
+ if (tracker)
+ tracker->invalidateResourceCalls++;
}
void freeResource(QOpenGLContext *context)
{
Q_ASSERT(context == QOpenGLContext::currentContext());
resource = 0;
- tracker->freeResourceCalls++;
+ if (tracker)
+ tracker->freeResourceCalls++;
}
int resource;
@@ -195,6 +206,28 @@ void tst_QOpenGL::multiGroupSharedResourceCleanup()
// Shouldn't crash when application exits.
}
+void tst_QOpenGL::multiGroupSharedResourceCleanupCustom()
+{
+ QWindow window;
+ window.setGeometry(0, 0, 10, 10);
+ window.create();
+
+ QOpenGLContext *ctx = new QOpenGLContext();
+ ctx->create();
+ ctx->makeCurrent(&window);
+
+ QOpenGLMultiGroupSharedResource multiGroupSharedResource;
+ SharedResource *resource = multiGroupSharedResource.value<SharedResource>(ctx);
+ SharedResourceTracker tracker;
+ resource->tracker = &tracker;
+
+ delete ctx;
+
+ QCOMPARE(tracker.invalidateResourceCalls, 1);
+ QCOMPARE(tracker.freeResourceCalls, 0);
+ QCOMPARE(tracker.destructorCalls, 1);
+}
+
static bool fuzzyComparePixels(const QRgb testPixel, const QRgb refPixel, const char* file, int line, int x = -1, int y = -1)
{
static int maxFuzz = 1;