From c0f62268b7d24e65a1f8724a056b43394c195324 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Mon, 1 Nov 2021 16:29:29 -0500 Subject: [PATCH] Widgets: Catch error when trying to install event filter in WebView --- spyder/widgets/browser.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/spyder/widgets/browser.py b/spyder/widgets/browser.py index ddb00fe8821..5049e2e389c 100644 --- a/spyder/widgets/browser.py +++ b/spyder/widgets/browser.py @@ -367,9 +367,15 @@ def setHtml(self, html, baseUrl=QUrl()): else: super(WebView, self).setHtml(html, baseUrl) - # The event filter needs to be installed every time html is set - # because the proxy changes with new content. - self.focusProxy().installEventFilter(self) + # This is required to catch an error with PyQt 5.9, for which + # it seems this functionality is not working. + # Fixes spyder-ide/spyder#16703 + try: + # The event filter needs to be installed every time html is set + # because the proxy changes with new content. + self.focusProxy().installEventFilter(self) + except AttributeError: + pass def load(self, url): """