summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/opengl/qgl.cpp1
-rw-r--r--src/opengl/qgl_p.h2
-rw-r--r--src/opengl/qgl_qpa.cpp12
3 files changed, 13 insertions, 2 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index a78c602701..ad53b20098 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1532,6 +1532,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
q->setDevice(dev);
guiGlContext = 0;
+ ownContext = false;
fbo = 0;
crWin = false;
initDone = false;
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 6f418a9818..668728be20 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -299,6 +299,8 @@ public:
void swapRegion(const QRegion &region);
QOpenGLContext *guiGlContext;
+ bool ownContext;
+
void setupSharing();
QGLFormat glFormat;
diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp
index 46dfd54adf..afa2772a6f 100644
--- a/src/opengl/qgl_qpa.cpp
+++ b/src/opengl/qgl_qpa.cpp
@@ -148,7 +148,9 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
widget->winId();//make window
}
- delete d->guiGlContext;
+ if (d->ownContext)
+ delete d->guiGlContext;
+ d->ownContext = true;
QOpenGLContext *shareGlContext = shareContext ? shareContext->d_func()->guiGlContext : 0;
d->guiGlContext = new QOpenGLContext;
d->guiGlContext->setFormat(winFormat);
@@ -180,8 +182,13 @@ void QGLContext::reset()
d->initDone = false;
QGLContextGroup::removeShare(this);
if (d->guiGlContext) {
- d->guiGlContext->setQGLContextHandle(0,0);
+ if (d->ownContext)
+ delete d->guiGlContext;
+ else
+ d->guiGlContext->setQGLContextHandle(0,0);
+ d->guiGlContext = 0;
}
+ d->ownContext = false;
}
void QGLContext::makeCurrent()
@@ -385,6 +392,7 @@ QGLContext::QGLContext(QOpenGLContext *context)
d->init(0, QGLFormat::fromSurfaceFormat(context->format()));
d->guiGlContext = context;
d->guiGlContext->setQGLContextHandle(this,qDeleteQGLContext);
+ d->ownContext = false;
d->valid = context->isValid();
d->setupSharing();
}