Improve error handling in version.opengl_vendor()

Not being able to get versionFunctions is now handled, and the cleanup is done
in a finally: block.
This commit is contained in:
Florian Bruhin 2017-06-09 23:14:34 +02:00
parent 9c851293ac
commit 89218c9d31

View File

@ -409,18 +409,21 @@ def opengl_vendor(): # pragma: no cover
log.init.debug("opengl_vendor: Making context current failed!") log.init.debug("opengl_vendor: Making context current failed!")
return None return None
if ctx.isOpenGLES(): try:
# Can't use versionFunctions there if ctx.isOpenGLES():
return None # Can't use versionFunctions there
return None
vp = QOpenGLVersionProfile() vp = QOpenGLVersionProfile()
vp.setVersion(2, 0) vp.setVersion(2, 0)
vf = ctx.versionFunctions(vp) vf = ctx.versionFunctions(vp)
vendor = vf.glGetString(vf.GL_VENDOR) if vf is None:
ctx.doneCurrent() log.init.debug("opengl_vendor: Getting version functions failed!")
return None
if old_context and old_surface: return vf.glGetString(vf.GL_VENDOR)
old_context.makeCurrent(old_surface) finally:
ctx.doneCurrent()
return vendor if old_context and old_surface:
old_context.makeCurrent(old_surface)