Add a better workaround for QTBUG-54419
Whenever we open a new tab in createWindow, we now set an attribute marking it - as soon as its URL changes the first time, we then close and re-open it in a new tab in TabbedBrowser.
This commit is contained in:
parent
67ad5c9837
commit
645a9aa6e1
@ -467,6 +467,7 @@ class WebEngineTab(browsertab.AbstractTab):
|
|||||||
# init js stuff
|
# init js stuff
|
||||||
self._init_js()
|
self._init_js()
|
||||||
self._child_event_filter = None
|
self._child_event_filter = None
|
||||||
|
self.needs_qtbug54419_workaround = False
|
||||||
|
|
||||||
def _init_js(self):
|
def _init_js(self):
|
||||||
js_code = '\n'.join([
|
js_code = '\n'.join([
|
||||||
|
@ -67,15 +67,6 @@ class WebEngineView(QWebEngineView):
|
|||||||
debug_type = debug.qenum_key(QWebEnginePage, wintype)
|
debug_type = debug.qenum_key(QWebEnginePage, wintype)
|
||||||
log.webview.debug("createWindow with type {}".format(debug_type))
|
log.webview.debug("createWindow with type {}".format(debug_type))
|
||||||
|
|
||||||
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-54419
|
|
||||||
vercheck = qtutils.version_check
|
|
||||||
qtbug_54419_fixed = ((vercheck('5.6.2') and not vercheck('5.7.0')) or
|
|
||||||
qtutils.version_check('5.7.1') or
|
|
||||||
os.environ.get('QUTE_QTBUG54419_PATCHED', ''))
|
|
||||||
if not qtbug_54419_fixed:
|
|
||||||
log.webview.debug("Ignoring createWindow because of QTBUG-54419")
|
|
||||||
return None
|
|
||||||
|
|
||||||
background = False
|
background = False
|
||||||
if wintype in [QWebEnginePage.WebBrowserWindow,
|
if wintype in [QWebEnginePage.WebBrowserWindow,
|
||||||
QWebEnginePage.WebDialog]:
|
QWebEnginePage.WebDialog]:
|
||||||
@ -91,8 +82,17 @@ class WebEngineView(QWebEngineView):
|
|||||||
|
|
||||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||||
window=self._win_id)
|
window=self._win_id)
|
||||||
# pylint: disable=protected-access
|
tab = tabbed_browser.tabopen(background=background)
|
||||||
return tabbed_browser.tabopen(background=background)._widget
|
|
||||||
|
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-54419
|
||||||
|
vercheck = qtutils.version_check
|
||||||
|
qtbug54419_fixed = ((vercheck('5.6.2') and not vercheck('5.7.0')) or
|
||||||
|
qtutils.version_check('5.7.1') or
|
||||||
|
os.environ.get('QUTE_QTBUG54419_PATCHED', ''))
|
||||||
|
if not qtbug54419_fixed:
|
||||||
|
tab.needs_qtbug54419_workaround = True
|
||||||
|
|
||||||
|
return tab._widget # pylint: disable=protected-access
|
||||||
|
|
||||||
|
|
||||||
class WebEnginePage(QWebEnginePage):
|
class WebEnginePage(QWebEnginePage):
|
||||||
|
@ -515,9 +515,23 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
except TabDeletedError:
|
except TabDeletedError:
|
||||||
# We can get signals for tabs we already deleted...
|
# We can get signals for tabs we already deleted...
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.page_title(idx):
|
if not self.page_title(idx):
|
||||||
self.set_page_title(idx, url.toDisplayString())
|
self.set_page_title(idx, url.toDisplayString())
|
||||||
|
|
||||||
|
# If needed, re-open the tab as a workaround for QTBUG-54419.
|
||||||
|
# See https://bugreports.qt.io/browse/QTBUG-54419
|
||||||
|
if tab.needs_qtbug54419_workaround:
|
||||||
|
log.misc.debug("Doing QTBUG-54419 workaround for {}, "
|
||||||
|
"url {}".format(tab, url))
|
||||||
|
self.setUpdatesEnabled(False)
|
||||||
|
try:
|
||||||
|
self.tabopen(url)
|
||||||
|
self.close_tab(tab, add_undo=False)
|
||||||
|
finally:
|
||||||
|
self.setUpdatesEnabled(True)
|
||||||
|
tab.needs_qtbug54419_workaround = False
|
||||||
|
|
||||||
@pyqtSlot(browsertab.AbstractTab, QIcon)
|
@pyqtSlot(browsertab.AbstractTab, QIcon)
|
||||||
def on_icon_changed(self, tab, icon):
|
def on_icon_changed(self, tab, icon):
|
||||||
"""Set the icon of a tab.
|
"""Set the icon of a tab.
|
||||||
|
Loading…
Reference in New Issue
Block a user