Return false on context creation failure

Make QOpenGLContext::create() return false when the native context
could not be initialized. This way the return value and isValid()
become equivalent.

Relying on on having a non-NULL platform context is not enough, many
platforms will return a new instance even if the underlying platform
code failed to create a native context. To ensure that a platform
context is really usable, isValid() has to be checked too.

Change-Id: I6b4e9fdb24347ad52fbd6edbb8d144d51e16c301
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Laszlo Agocs 2014-03-19 16:00:40 +01:00 committed by The Qt Project
parent 9508ea4c50
commit f5b552b590

View File

@ -247,8 +247,8 @@ QMutex QOpenGLContextPrivate::makeCurrentTrackerMutex;
To set up a context, set its screen and format such that they match those
of the surface or surfaces with which the context is meant to be used, if
necessary make it share resources with other contexts with
setShareContext(), and finally call create(). Use isValid() to check if the
context was successfully initialized.
setShareContext(), and finally call create(). Use the return value or isValid()
to check if the context was successfully initialized.
A context can be made current against a given surface by calling
makeCurrent(). When OpenGL rendering is done, call swapBuffers() to swap
@ -491,7 +491,7 @@ bool QOpenGLContext::create()
d->shareContext = 0;
d->shareGroup = d->shareContext ? d->shareContext->shareGroup() : new QOpenGLContextGroup;
d->shareGroup->d_func()->addContext(this);
return d->platformGLContext;
return isValid();
}
/*!