diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp index a27bdaccde..e7fd2f79a4 100644 --- a/src/gui/kernel/qsurface.cpp +++ b/src/gui/kernel/qsurface.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qsurface.h" +#include "qopenglcontext.h" QT_BEGIN_NAMESPACE @@ -130,6 +131,11 @@ QSurface::QSurface(SurfaceClass type) */ QSurface::~QSurface() { +#ifndef QT_NO_OPENGL + QOpenGLContext *context = QOpenGLContext::currentContext(); + if (context && context->surface() == this) + context->doneCurrent(); +#endif } /*!