From 7fab169a86c33eb6a91f1792f875c2bcf2810f79 Mon Sep 17 00:00:00 2001 From: Loren Eteval Date: Thu, 7 Mar 2024 13:29:12 +0800 Subject: [PATCH] Add exception check in toURI() call Signed-off-by: Loren Eteval --- Furious/Widget/UserServersQTableWidget.py | 12 +++++++++++- Furious/Window/QRCodeWindow.py | 7 ++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Furious/Widget/UserServersQTableWidget.py b/Furious/Widget/UserServersQTableWidget.py index 3631d8f1..9fc7681d 100644 --- a/Furious/Widget/UserServersQTableWidget.py +++ b/Furious/Widget/UserServersQTableWidget.py @@ -1201,9 +1201,19 @@ class UserServersQTableWidget(QTranslatable, AppQTableWidget): # Nothing selected. Do nothing return + def toURI(factory) -> str: + assert isinstance(factory, ConfigurationFactory) + + try: + return factory.toURI() + except Exception: + # Any non-exit exceptions + + return '' + # TODO: MessageBox? QApplication.clipboard().setText( - '\n'.join(list(AS_UserServers()[index].toURI() for index in indexes)) + '\n'.join(list(toURI(AS_UserServers()[index]) for index in indexes)) ) def exportSelectedItemQR(self): diff --git a/Furious/Window/QRCodeWindow.py b/Furious/Window/QRCodeWindow.py index 321ca39f..0fb94929 100644 --- a/Furious/Window/QRCodeWindow.py +++ b/Furious/Window/QRCodeWindow.py @@ -57,7 +57,12 @@ class QRCodeWindow(SupportImplicitReference, AppQMainWindow): config = AS_UserServers()[index] - uri = config.toURI() + try: + uri = config.toURI() + except Exception: + # Any non-exit exceptions + + uri = '' if uri: qrcode = pyqrcode.create(uri)