mirror of
https://github.com/ankitects/anki.git
synced 2025-11-13 08:07:11 -05:00
Print qt context if it exists
https://stackoverflow.com/questions/42561295/qt-error-is-printed-on-the-console-how-to-see-where-it-originates-from https://stackoverflow.com/questions/35894171/redirect-qdebug-output-to-file-with-pyqt5 https://anki.tenderapp.com/discussions/ankidesktop/42070-anki-closes-without-warning-when-importing-conflicting-shared-deck https://doc.qt.io/qt-5/qtglobal.html#qInstallMessageHandler
This commit is contained in:
parent
9594a3ef9b
commit
25ff525cc9
1 changed files with 11 additions and 3 deletions
|
|
@ -326,17 +326,25 @@ def setupGL(pm):
|
||||||
|
|
||||||
# catch opengl errors
|
# catch opengl errors
|
||||||
def msgHandler(type, ctx, msg):
|
def msgHandler(type, ctx, msg):
|
||||||
|
context = ""
|
||||||
|
if ctx.file:
|
||||||
|
context += f"{ctx.file}:"
|
||||||
|
if ctx.line:
|
||||||
|
context += f"{ctx.line},"
|
||||||
|
if ctx.function:
|
||||||
|
context += f"{ctx.function}"
|
||||||
|
if context:
|
||||||
|
context = f"'{context}'"
|
||||||
if "Failed to create OpenGL context" in msg:
|
if "Failed to create OpenGL context" in msg:
|
||||||
QMessageBox.critical(
|
QMessageBox.critical(
|
||||||
None,
|
None,
|
||||||
"Error",
|
"Error",
|
||||||
"Error loading '%s' graphics driver. Please start Anki again to try next driver."
|
f"Error loading '{mode}' graphics driver. Please start Anki again to try next driver. {context}",
|
||||||
% mode,
|
|
||||||
)
|
)
|
||||||
pm.nextGlMode()
|
pm.nextGlMode()
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
print("qt:", msg)
|
print(f"qt: {msg} {context}")
|
||||||
|
|
||||||
qInstallMessageHandler(msgHandler)
|
qInstallMessageHandler(msgHandler)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue