diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-06-21 14:44:41 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-06-22 08:54:45 +0000 |
commit | 1569f46bdcffc9b4af3eed295aa29fa85e33f60c (patch) | |
tree | f85883fb1e9378dffc705a03e5f35146ffd5df1b /src/quick/scenegraph/util | |
parent | 7de18e6f52d6247bddd7bfabe0b2601d7db239b5 (diff) |
Make QSGEngine::initialize backend-independent
Allow calling initialize(nullptr) regardless of which scenegraph backend
is in use.
Change-Id: Ie5965dcd12d423255d5eb85fed255107cac2acb9
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/quick/scenegraph/util')
-rw-r--r-- | src/quick/scenegraph/util/qsgengine.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/quick/scenegraph/util/qsgengine.cpp b/src/quick/scenegraph/util/qsgengine.cpp index 26a3d66077..f4d86bba04 100644 --- a/src/quick/scenegraph/util/qsgengine.cpp +++ b/src/quick/scenegraph/util/qsgengine.cpp @@ -115,23 +115,21 @@ QSGEngine::~QSGEngine() */ void QSGEngine::initialize(QOpenGLContext *context) { -#ifndef QT_NO_OPENGL Q_D(QSGEngine); - if (QOpenGLContext::currentContext() != context) { +#ifdef QT_NO_OPENGL + if (context && QOpenGLContext::currentContext() != context) { qWarning("WARNING: The context must be current before calling QSGEngine::initialize."); return; } - - auto openGLRenderContext = static_cast<QSGDefaultRenderContext *>(d->sgRenderContext.data()); - - if (openGLRenderContext != nullptr && !openGLRenderContext->isValid()) { - openGLRenderContext->setAttachToGLContext(false); - openGLRenderContext->initialize(context); - connect(context, &QOpenGLContext::aboutToBeDestroyed, this, &QSGEngine::invalidate); - } -#else - Q_UNUSED(context) #endif + if (d->sgRenderContext && !d->sgRenderContext->isValid()) { + d->sgRenderContext->setAttachToGraphicsContext(false); + d->sgRenderContext->initialize(context); +#ifndef QT_NO_OPENGL + if (context) + connect(context, &QOpenGLContext::aboutToBeDestroyed, this, &QSGEngine::invalidate); +#endif + } } /*! |