Add workaround for PyQt 5.11 headerDataChanged bug

https://www.riverbankcomputing.com/pipermail/pyqt/2018-June/040445.html
This commit is contained in:
Florian Bruhin 2018-06-23 17:21:55 +02:00
parent c3455d9082
commit eca08f064b
5 changed files with 28 additions and 4 deletions

View File

@ -21,7 +21,8 @@ v1.4.0 (unreleased)
Added Added
~~~~~ ~~~~~
- Support for the bundled `sip` module in PyQt 5.11. - Support for the bundled `sip` module in PyQt 5.11 and workarounds for
PyQt 5.11 bugs.
- New `--debug-flag log-requests` to log requests to the debug log for - New `--debug-flag log-requests` to log requests to the debug log for
debugging. debugging.
- New `--first` flag for `:hint` (bound to `gi` for inputs) which automatically - New `--first` flag for `:hint` (bound to `gi` for inputs) which automatically

View File

@ -30,7 +30,7 @@ import tempfile
import enum import enum
from PyQt5.QtCore import (pyqtSlot, pyqtSignal, Qt, QObject, QModelIndex, from PyQt5.QtCore import (pyqtSlot, pyqtSignal, Qt, QObject, QModelIndex,
QTimer, QAbstractListModel, QUrl) QTimer, QAbstractListModel, QUrl, PYQT_VERSION)
from qutebrowser.commands import cmdexc, cmdutils from qutebrowser.commands import cmdexc, cmdutils
from qutebrowser.config import config from qutebrowser.config import config
@ -878,6 +878,11 @@ class DownloadModel(QAbstractListModel):
"""A list model showing downloads.""" """A list model showing downloads."""
if PYQT_VERSION == 0x050b00:
# WORKAROUND for PyQt 5.11 bug:
# https://www.riverbankcomputing.com/pipermail/pyqt/2018-June/040445.html
headerDataChanged = pyqtSignal(Qt.Orientation, int, int)
def __init__(self, qtnetwork_manager, webengine_manager=None, parent=None): def __init__(self, qtnetwork_manager, webengine_manager=None, parent=None):
super().__init__(parent) super().__init__(parent)
self._qtnetwork_manager = qtnetwork_manager self._qtnetwork_manager = qtnetwork_manager

View File

@ -19,7 +19,8 @@
"""A model that proxies access to one or more completion categories.""" """A model that proxies access to one or more completion categories."""
from PyQt5.QtCore import Qt, QModelIndex, QAbstractItemModel from PyQt5.QtCore import (Qt, QModelIndex, QAbstractItemModel, pyqtSignal,
PYQT_VERSION)
from qutebrowser.utils import log, qtutils from qutebrowser.utils import log, qtutils
from qutebrowser.commands import cmdexc from qutebrowser.commands import cmdexc
@ -38,6 +39,11 @@ class CompletionModel(QAbstractItemModel):
_categories: The sub-categories. _categories: The sub-categories.
""" """
if PYQT_VERSION == 0x050b00:
# WORKAROUND for PyQt 5.11 bug:
# https://www.riverbankcomputing.com/pipermail/pyqt/2018-June/040445.html
headerDataChanged = pyqtSignal(Qt.Orientation, int, int)
def __init__(self, *, column_widths=(30, 70, 0), parent=None): def __init__(self, *, column_widths=(30, 70, 0), parent=None):
super().__init__(parent) super().__init__(parent)
self.column_widths = column_widths self.column_widths = column_widths

View File

@ -19,6 +19,7 @@
"""A completion category that queries the SQL History store.""" """A completion category that queries the SQL History store."""
from PyQt5.QtCore import pyqtSignal, Qt, PYQT_VERSION
from PyQt5.QtSql import QSqlQueryModel from PyQt5.QtSql import QSqlQueryModel
from qutebrowser.misc import sql from qutebrowser.misc import sql
@ -30,6 +31,11 @@ class HistoryCategory(QSqlQueryModel):
"""A completion category that queries the SQL History store.""" """A completion category that queries the SQL History store."""
if PYQT_VERSION == 0x050b00:
# WORKAROUND for PyQt 5.11 bug:
# https://www.riverbankcomputing.com/pipermail/pyqt/2018-June/040445.html
headerDataChanged = pyqtSignal(Qt.Orientation, int, int)
def __init__(self, *, delete_func=None, parent=None): def __init__(self, *, delete_func=None, parent=None):
"""Create a new History completion category.""" """Create a new History completion category."""
super().__init__(parent=parent) super().__init__(parent=parent)

View File

@ -21,7 +21,8 @@
import re import re
from PyQt5.QtCore import Qt, QSortFilterProxyModel, QRegExp from PyQt5.QtCore import (Qt, QSortFilterProxyModel, QRegExp, PYQT_VERSION,
pyqtSignal)
from PyQt5.QtGui import QStandardItem, QStandardItemModel from PyQt5.QtGui import QStandardItem, QStandardItemModel
from qutebrowser.utils import qtutils from qutebrowser.utils import qtutils
@ -31,6 +32,11 @@ class ListCategory(QSortFilterProxyModel):
"""Expose a list of items as a category for the CompletionModel.""" """Expose a list of items as a category for the CompletionModel."""
if PYQT_VERSION == 0x050b00:
# WORKAROUND for PyQt 5.11 bug:
# https://www.riverbankcomputing.com/pipermail/pyqt/2018-June/040445.html
headerDataChanged = pyqtSignal(Qt.Orientation, int, int)
def __init__(self, name, items, sort=True, delete_func=None, parent=None): def __init__(self, name, items, sort=True, delete_func=None, parent=None):
super().__init__(parent) super().__init__(parent)
self.name = name self.name = name