Use showText to show add-on import errors (#2103)

* Use showText to show add-on import errors

Long error messages can be completely unreadable as QMessageBox doesn't
show a scrollbar and the text can't be selected and copied by default (on Windows at least).

* HTML-escape error
This commit is contained in:
Abdo 2022-10-06 11:15:56 +03:00 committed by GitHub
parent d7b982ec9a
commit 9d6cd4cd76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,7 @@
from __future__ import annotations
import html
import io
import json
import os
@ -45,6 +46,7 @@ from aqt.utils import (
send_to_trash,
show_info,
showInfo,
showText,
showWarning,
tooltip,
tr,
@ -246,12 +248,18 @@ class AddonManager:
except AbortAddonImport:
pass
except:
showWarning(
error = html.escape(
tr.addons_failed_to_load(
name=addon.human_name(),
traceback=traceback.format_exc(),
)
)
txt = f"<h1>{tr.qt_misc_error()}</h1><div style='white-space: pre-wrap'>{error}</div>"
showText(
txt,
type="html",
copyBtn=True,
)
def onAddonsDialog(self) -> None:
aqt.dialogs.open("AddonsDialog", self)