diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-21 17:34:21 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-21 17:34:21 (GMT) |
commit | 191df7e5575cb5b8d56846d82d405a8f0dd07fa9 (patch) | |
tree | 523036a7525fa0e57316a91c24aa31a0c600e658 /src | |
parent | eee847d00f6de755909d6f913430da662f26c503 (diff) | |
parent | 5cfefb0f71e4f4587f1c31d3d785136a9655085b (diff) | |
download | Qt-191df7e5575cb5b8d56846d82d405a8f0dd07fa9.zip Qt-191df7e5575cb5b8d56846d82d405a8f0dd07fa9.tar.gz Qt-191df7e5575cb5b8d56846d82d405a8f0dd07fa9.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2:
Fixed an assert in QMenu
Call eglTerminate() when the last QEglContext is destroyed to free mem.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/egl/qegl.cpp | 37 | ||||
-rw-r--r-- | src/gui/widgets/qmenu.cpp | 12 |
2 files changed, 34 insertions, 15 deletions
diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index ee19216..c16aeb1 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -42,11 +42,40 @@ #include <QtGui/qpaintdevice.h> #include <QtGui/qpixmap.h> #include <QtGui/qwidget.h> +#include <QtCore/qatomic.h> #include <QtCore/qdebug.h> #include "qegl_p.h" QT_BEGIN_NAMESPACE + +/* + QEglContextTracker is used to track the EGL contexts that we + create internally in Qt, so that we can call eglTerminate() to + free additional EGL resources when the last context is destroyed. +*/ + +class QEglContextTracker +{ +public: + static void ref() { contexts.ref(); } + static void deref() { + if (!contexts.deref()) { + eglTerminate(QEglContext::display()); + displayOpen = 0; + } + } + static void setDisplayOpened() { displayOpen = 1; } + static bool displayOpened() { return displayOpen; } + +private: + static QAtomicInt contexts; + static QAtomicInt displayOpen; +}; + +QAtomicInt QEglContextTracker::contexts = 0; +QAtomicInt QEglContextTracker::displayOpen = 0; + // Current GL and VG contexts. These are used to determine if // we can avoid an eglMakeCurrent() after a call to lazyDoneCurrent(). // If a background thread modifies the value, the worst that will @@ -65,6 +94,7 @@ QEglContext::QEglContext() , ownsContext(true) , sharing(false) { + QEglContextTracker::ref(); } QEglContext::~QEglContext() @@ -75,6 +105,7 @@ QEglContext::~QEglContext() currentGLContext = 0; if (currentVGContext == this) currentVGContext = 0; + QEglContextTracker::deref(); } bool QEglContext::isValid() const @@ -361,11 +392,9 @@ QEglProperties QEglContext::configProperties(EGLConfig cfg) const EGLDisplay QEglContext::display() { - static bool openedDisplay = false; - - if (!openedDisplay) { + if (!QEglContextTracker::displayOpened()) { dpy = eglGetDisplay(nativeDisplay()); - openedDisplay = true; + QEglContextTracker::setDisplayOpened(); if (dpy == EGL_NO_DISPLAY) { qWarning("QEglContext::display(): Falling back to EGL_DEFAULT_DISPLAY"); dpy = eglGetDisplay(EGLNativeDisplayType(EGL_DEFAULT_DISPLAY)); diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 879ba2a..c05829a 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -992,19 +992,9 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) return false; } -class ExceptionGuard -{ -public: - inline ExceptionGuard(bool *w = 0) : watched(w) { Q_ASSERT(!(*watched)); *watched = true; } - inline ~ExceptionGuard() { *watched = false; } - inline operator bool() { return *watched; } -private: - bool *watched; -}; - void QMenuPrivate::activateCausedStack(const QList<QPointer<QWidget> > &causedStack, QAction *action, QAction::ActionEvent action_e, bool self) { - ExceptionGuard guard(&activationRecursionGuard); + QBoolBlocker guard(activationRecursionGuard); #ifdef QT3_SUPPORT const int actionId = q_func()->findIdForAction(action); #endif |