Only cleanup share widget if it has been created.

Without this change a not yet created share widget is created
once qt_destroy_gl_share_widget() is called. As creating the
widget also triggers a call to qt_cleanup_gl_share_widget() once
QApplication is destroyed a QApplication created afterwards
cannot use a share widget anymore.
This functionality is needed for Harmattan.

Merge-request: 2609
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
(cherry picked from commit 8680d831fb7066feae07690a4a6bc8e908a84e5a)
This commit is contained in:
Armin Berres 2011-05-02 15:17:39 +02:00 committed by Olivier Goffart
parent f1e0993419
commit 0b2f70a5de

View File

@ -184,7 +184,9 @@ QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL)
class QGLGlobalShareWidget
{
public:
QGLGlobalShareWidget() : firstPixmap(0), widgetRefCount(0), widget(0), initializing(false) {}
QGLGlobalShareWidget() : firstPixmap(0), widgetRefCount(0), widget(0), initializing(false) {
created = true;
}
QGLWidget *shareWidget() {
if (!initializing && !widget && !cleanedUp) {
@ -223,6 +225,7 @@ public:
}
static bool cleanedUp;
static bool created;
QGLPixmapData *firstPixmap;
int widgetRefCount;
@ -233,6 +236,7 @@ private:
};
bool QGLGlobalShareWidget::cleanedUp = false;
bool QGLGlobalShareWidget::created = false;
static void qt_cleanup_gl_share_widget();
Q_GLOBAL_STATIC_WITH_INITIALIZER(QGLGlobalShareWidget, _qt_gl_share_widget,
@ -242,6 +246,7 @@ Q_GLOBAL_STATIC_WITH_INITIALIZER(QGLGlobalShareWidget, _qt_gl_share_widget,
static void qt_cleanup_gl_share_widget()
{
if (QGLGlobalShareWidget::created)
_qt_gl_share_widget()->cleanup();
}
@ -254,6 +259,7 @@ QGLWidget* qt_gl_share_widget()
void qt_destroy_gl_share_widget()
{
if (QGLGlobalShareWidget::created)
_qt_gl_share_widget()->destroy();
}