From 1af951fd62b4878b2eaeb63e628b0ce5c06eeae8 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 8 Feb 2017 10:55:42 +0100 Subject: [PATCH] Work around crashes when opening URL after renderer crash Fixes #2290 --- CHANGELOG.asciidoc | 1 + qutebrowser/mainwindow/tabbedbrowser.py | 15 ++++++++++++--- tests/end2end/features/misc.feature | 13 +++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 62170d6e1..43dc54ba1 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -61,6 +61,7 @@ Fixed - Fixed starting on newer PyQt/sip versions with LibreSSL - When downloading files with QtWebKit, a User-Agent header is set when possible. - Fixed showing of keybindings in the :help completion +- Worked around a segfault when opening a URL after a QtWebEngine renderer process crash v0.9.1 ------ diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index 204dcdf7a..31eef4793 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -250,12 +250,13 @@ class TabbedBrowser(tabwidget.TabWidget): url = config.get('general', 'default-page') self.openurl(url, newtab=True) - def _remove_tab(self, tab, *, add_undo=True): + def _remove_tab(self, tab, *, add_undo=True, crashed=False): """Remove a tab from the tab list and delete it properly. Args: tab: The QWebView to be closed. add_undo: Whether the tab close can be undone. + crashed: Whether we're closing a tab with crashed renderer process. """ idx = self.indexOf(tab) if idx == -1: @@ -285,8 +286,10 @@ class TabbedBrowser(tabwidget.TabWidget): urlutils.invalid_url_error(tab.url(), "saving tab") tab.shutdown() self.removeTab(idx) - tab.layout().unwrap() - tab.deleteLater() + if not crashed: + # WORKAROUND for a segfault when we delete the crashed tab. + # see https://bugreports.qt.io/browse/QTBUG-58698 + tab.layout().unwrap() def undo(self): """Undo removing of a tab.""" @@ -671,6 +674,12 @@ class TabbedBrowser(tabwidget.TabWidget): else: raise ValueError("Invalid status {}".format(status)) + # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-58698 + # FIXME:qtwebengine can we disable this with Qt 5.8.1? + self._remove_tab(tab, crashed=True) + if self.count() == 0: + self.tabopen(QUrl('about:blank')) + def resizeEvent(self, e): """Extend resizeEvent of QWidget to emit a resized signal afterwards. diff --git a/tests/end2end/features/misc.feature b/tests/end2end/features/misc.feature index 0d843de14..fe1c3b256 100644 --- a/tests/end2end/features/misc.feature +++ b/tests/end2end/features/misc.feature @@ -653,3 +653,16 @@ Feature: Various utility commands. Scenario: Renderer kill When I run :open -t chrome://kill Then the error "Renderer process was killed" should be shown + + # https://github.com/qutebrowser/qutebrowser/issues/2290 + @qtwebkit_skip @no_invalid_lines + Scenario: Navigating to URL after renderer process is gone + When I run :tab-only + And I open data/numbers/1.txt + And I open data/numbers/2.txt in a new tab + And I run :open chrome://kill + And I wait for "Renderer process was killed" in the log + And I open data/numbers/3.txt + Then no crash should happen + And the following tabs should be open: + - data/numbers/3.txt (active)