From 5442b0b70a94655729caf4f68c0e5bd3bdaf4087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Tue, 14 Sep 2021 13:00:14 +0200 Subject: [PATCH] uri-dialog: Catch errors when reading from clipboard The clipboard.read_text_finish method might throw an error when something goes wrong. Catch it and print in debug message. There is no alternative clipboard reading, so simply ignore. --- src/dialogs.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/dialogs.js b/src/dialogs.js index 882a659c..e7216084 100644 --- a/src/dialogs.js +++ b/src/dialogs.js @@ -193,8 +193,17 @@ class ClapperUriDialog extends Gtk.Dialog _readTextAsyncCb(clipboard, result) { - const uri = clipboard.read_text_finish(result); - if(!uri || !Gst.uri_is_valid(uri)) return; + let uri = null; + + try { + uri = clipboard.read_text_finish(result); + } + catch(err) { + debug(`could not read clipboard: ${err.message}`); + } + + if(!uri || !Gst.uri_is_valid(uri)) + return; const contentBox = this.get_content_area(); const linkEntry = contentBox.get_last_child();