Make version.opengl_vendor() work with an existing context
This makes it possible to use it in :debug-console
This commit is contained in:
parent
a858611bb9
commit
4d64bcc852
@ -391,7 +391,9 @@ def opengl_vendor(): # pragma: no cover
|
||||
from PyQt5.QtGui import (QOpenGLContext, QOpenGLVersionProfile,
|
||||
QOffscreenSurface)
|
||||
assert QApplication.instance()
|
||||
assert QOpenGLContext.currentContext() is None
|
||||
|
||||
old_context = QOpenGLContext.currentContext()
|
||||
old_surface = None if old_context is None else old_context.surface()
|
||||
|
||||
surface = QOffscreenSurface()
|
||||
surface.create()
|
||||
@ -418,4 +420,7 @@ def opengl_vendor(): # pragma: no cover
|
||||
vendor = vf.glGetString(vf.GL_VENDOR)
|
||||
ctx.doneCurrent()
|
||||
|
||||
if old_context and old_surface:
|
||||
old_context.makeCurrent(old_surface)
|
||||
|
||||
return vendor
|
||||
|
Loading…
Reference in New Issue
Block a user