mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
detect and refuse to run on nouveau
This commit is contained in:
parent
a6c34fd79f
commit
4c6c0d428b
2 changed files with 52 additions and 0 deletions
|
@ -340,6 +340,13 @@ environment points to a valid, writable folder.""")
|
||||||
# i18n
|
# i18n
|
||||||
setupLang(pm, app, opts.lang)
|
setupLang(pm, app, opts.lang)
|
||||||
|
|
||||||
|
if isLin and pm.glMode() == "auto":
|
||||||
|
from aqt.utils import gfxDriverIsBroken
|
||||||
|
if gfxDriverIsBroken():
|
||||||
|
pm.nextGlMode()
|
||||||
|
QMessageBox.critical(None, "Error", "Your video driver is incompatible. Please start Anki again, and Anki will switch to a slower, more compatible mode.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# remaining pm init
|
# remaining pm init
|
||||||
pm.ensureProfile()
|
pm.ensureProfile()
|
||||||
|
|
||||||
|
|
45
aqt/utils.py
45
aqt/utils.py
|
@ -527,3 +527,48 @@ def versionWithBuild():
|
||||||
except:
|
except:
|
||||||
build = "dev"
|
build = "dev"
|
||||||
return "%s (%s)" % (appVersion, build)
|
return "%s (%s)" % (appVersion, build)
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
# adapted from version detection in qutebrowser
|
||||||
|
def opengl_vendor():
|
||||||
|
old_context = QOpenGLContext.currentContext()
|
||||||
|
old_surface = None if old_context is None else old_context.surface()
|
||||||
|
|
||||||
|
surface = QOffscreenSurface()
|
||||||
|
surface.create()
|
||||||
|
|
||||||
|
ctx = QOpenGLContext()
|
||||||
|
ok = ctx.create()
|
||||||
|
if not ok:
|
||||||
|
return None
|
||||||
|
|
||||||
|
ok = ctx.makeCurrent(surface)
|
||||||
|
if not ok:
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
|
if ctx.isOpenGLES():
|
||||||
|
# Can't use versionFunctions there
|
||||||
|
return None
|
||||||
|
|
||||||
|
vp = QOpenGLVersionProfile()
|
||||||
|
vp.setVersion(2, 0)
|
||||||
|
|
||||||
|
try:
|
||||||
|
vf = ctx.versionFunctions(vp)
|
||||||
|
except ImportError as e:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if vf is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return vf.glGetString(vf.GL_VENDOR)
|
||||||
|
finally:
|
||||||
|
ctx.doneCurrent()
|
||||||
|
if old_context and old_surface:
|
||||||
|
old_context.makeCurrent(old_surface)
|
||||||
|
|
||||||
|
def gfxDriverIsBroken():
|
||||||
|
driver = opengl_vendor()
|
||||||
|
return driver == "nouveau"
|
||||||
|
|
Loading…
Reference in a new issue