diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-11-15 22:04:46 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-11-15 22:13:09 (GMT) |
commit | 0e74cc3e1a05147a8ae9c1c4be7c9f836da1acf3 (patch) | |
tree | b5917c87769d657b16d6b726d59c4e3ae1839d96 | |
parent | bb818bf70cef00bbdcafaac1bf017575baeab8dc (diff) | |
download | Qt-0e74cc3e1a05147a8ae9c1c4be7c9f836da1acf3.zip Qt-0e74cc3e1a05147a8ae9c1c4be7c9f836da1acf3.tar.gz Qt-0e74cc3e1a05147a8ae9c1c4be7c9f836da1acf3.tar.bz2 |
Make isSharing() reset to false when context no longer sharing
The documentation for QGLContext::isSharing() indicates that
the function returns true only when the context is sharing.
However, previously the sharing flag would stay on if the
context was created as sharing but is no longer sharing.
Task-number: QTBUG-5578
Reviewed-by: Sarah Smith
-rw-r--r-- | src/opengl/qgl.cpp | 2 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 1 | ||||
-rw-r--r-- | tests/auto/qgl/tst_qgl.cpp | 5 |
3 files changed, 7 insertions, 1 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 8063fc8..f8a2ea4 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -3030,7 +3030,7 @@ void QGLContext::setValid(bool valid) bool QGLContext::isSharing() const { Q_D(const QGLContext); - return d->sharing; + return d->group->isSharing(); } QGLFormat QGLContext::format() const diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 9a17c67..45b2942 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -233,6 +233,7 @@ public: QGLExtensionFuncs &extensionFuncs() {return m_extensionFuncs;} const QGLContext *context() const {return m_context;} + bool isSharing() const { return m_shares.size() >= 2; } void addGuard(QGLSharedResourceGuard *guard); void removeGuard(QGLSharedResourceGuard *guard); diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index ccb08c3..5dc072d 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -1842,6 +1842,7 @@ void tst_QGL::shareRegister() QVERIFY(qt_shared_test()->value(glw1->context()) == res1); // Create another context that shares with the first. + QVERIFY(!glw1->isSharing()); QGLWidget *glw2 = new QGLWidget(0, glw1); if (!glw2->isSharing()) { delete glw2; @@ -1880,6 +1881,7 @@ void tst_QGL::shareRegister() // Create a third context, not sharing with the others. QGLWidget *glw3 = new QGLWidget(); + QVERIFY(!glw3->isSharing()); // Create a guard on the standalone context. QGLSharedResourceGuard guard3(glw3->context()); @@ -1928,6 +1930,9 @@ void tst_QGL::shareRegister() // Delete the first context. delete glw1; + // The second context should no longer register as sharing. + QVERIFY(!glw2->isSharing()); + // The first context's resource should transfer to the second context. QCOMPARE(tst_QGLResource::deletions, 0); QVERIFY(qt_shared_test()->value(glw2->context()) == res1); |