diff options
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r-- | src/opengl/qgl.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index f8a9196..8b7674e 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1273,6 +1273,14 @@ bool operator!=(const QGLFormat& a, const QGLFormat& b) /***************************************************************************** QGLContext implementation *****************************************************************************/ +QGLContextPrivate::~QGLContextPrivate() +{ + if (!group->m_refs.deref()) { + Q_ASSERT(group->context() == q_ptr); + delete group; + } +} + void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) { Q_Q(QGLContext); @@ -4861,40 +4869,40 @@ bool QGLDrawable::autoFillBackground() const bool QGLShareRegister::checkSharing(const QGLContext *context1, const QGLContext *context2) { - bool sharing = (context1 && context2 && context1->d_ptr->groupResources == context2->d_ptr->groupResources); + bool sharing = (context1 && context2 && context1->d_ptr->group == context2->d_ptr->group); return sharing; } void QGLShareRegister::addShare(const QGLContext *context, const QGLContext *share) { Q_ASSERT(context && share); - if (context->d_ptr->groupResources == share->d_ptr->groupResources) + if (context->d_ptr->group == share->d_ptr->group) return; // Make sure 'context' is not already shared with another group of contexts. - Q_ASSERT(reg.find(context->d_ptr->groupResources) == reg.end()); - Q_ASSERT(context->d_ptr->groupResources->refs == 1); + Q_ASSERT(reg.find(context->d_ptr->group) == reg.end()); + Q_ASSERT(context->d_ptr->group->m_refs == 1); // Free 'context' group resources and make it use the same resources as 'share'. - delete context->d_ptr->groupResources; - context->d_ptr->groupResources = share->d_ptr->groupResources; - context->d_ptr->groupResources->refs.ref(); + delete context->d_ptr->group; + context->d_ptr->group = share->d_ptr->group; + context->d_ptr->group->m_refs.ref(); // Maintain a list of all the contexts in each group of sharing contexts. - SharingHash::iterator it = reg.find(share->d_ptr->groupResources); + SharingHash::iterator it = reg.find(share->d_ptr->group); if (it == reg.end()) - it = reg.insert(share->d_ptr->groupResources, ContextList() << share); + it = reg.insert(share->d_ptr->group, ContextList() << share); it.value() << context; } QList<const QGLContext *> QGLShareRegister::shares(const QGLContext *context) { - SharingHash::const_iterator it = reg.find(context->d_ptr->groupResources); + SharingHash::const_iterator it = reg.find(context->d_ptr->group); if (it == reg.end()) return ContextList(); return it.value(); } void QGLShareRegister::removeShare(const QGLContext *context) { - SharingHash::iterator it = reg.find(context->d_ptr->groupResources); + SharingHash::iterator it = reg.find(context->d_ptr->group); if (it == reg.end()) return; @@ -4902,6 +4910,10 @@ void QGLShareRegister::removeShare(const QGLContext *context) { Q_ASSERT(count == 1); Q_UNUSED(count); + // Update context group representative. + if (context->d_ptr->group->m_context == context) + context->d_ptr->group->m_context = it.value().first(); + Q_ASSERT(it.value().size() != 0); if (it.value().size() == 1) reg.erase(it); |