From 878fa262477b368efdfedad2102a65ee5cd64343 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 26 Jul 2016 12:55:40 +0200 Subject: [PATCH] Use real slots for QtWebKit signals Otherwise we can get this when immediately quitting: Traceback (most recent call last): File ".../qutebrowser/browser/webkit/webkittab.py", line 580, in not self._widget.page().error_occurred)) RuntimeError: wrapped C/C++ object of type WebView has been deleted --- qutebrowser/browser/webkit/webkittab.py | 29 +++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py index ef3dbdce4..e8366ffa2 100644 --- a/qutebrowser/browser/webkit/webkittab.py +++ b/qutebrowser/browser/webkit/webkittab.py @@ -557,6 +557,21 @@ class WebKitTab(browsertab.AbstractTab): def set_html(self, html, base_url): self._widget.setHtml(html, base_url) + @pyqtSlot() + def _on_frame_load_finished(self): + """Make sure we emit an appropriate status when loading finished. + + While Qt has a bool "ok" attribute for loadFinished, it always is True + when using error pages... See + https://github.com/The-Compiler/qutebrowser/issues/84 + """ + self._on_load_finished(not self._widget.page().error_occurred) + + @pyqtSlot() + def _on_webkit_icon_changed(self): + """Emit iconChanged with a QIcon like QWebEngineView does.""" + self.icon_changed.emit(self._widget.icon()) + def _connect_signals(self): view = self._widget page = view.page() @@ -570,15 +585,5 @@ class WebKitTab(browsertab.AbstractTab): view.urlChanged.connect(self._on_url_changed) view.shutting_down.connect(self.shutting_down) page.networkAccessManager().sslErrors.connect(self._on_ssl_errors) - - # Make sure we emit an appropriate status when loading finished. While - # Qt has a bool "ok" attribute for loadFinished, it always is True when - # using error pages... - # See https://github.com/The-Compiler/qutebrowser/issues/84 - frame.loadFinished.connect(lambda: - self._on_load_finished( - not self._widget.page().error_occurred)) - - # Emit iconChanged with a QIcon like QWebEngineView does. - view.iconChanged.connect(lambda: - self.icon_changed.emit(self._widget.icon())) + frame.loadFinished.connect(self._on_frame_load_finished) + view.iconChanged.connect(self._on_webkit_icon_changed)