Reintroduce downloadview workaround
This still seems to be an issue on AppVeyor
This commit is contained in:
parent
cf07bfc5c5
commit
db807a1bbc
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
"""The ListView to display downloads in."""
|
"""The ListView to display downloads in."""
|
||||||
|
|
||||||
|
import functools
|
||||||
|
|
||||||
|
import sip
|
||||||
from PyQt5.QtCore import pyqtSlot, QSize, Qt, QTimer
|
from PyQt5.QtCore import pyqtSlot, QSize, Qt, QTimer
|
||||||
from PyQt5.QtWidgets import QListView, QSizePolicy, QMenu, QStyleFactory
|
from PyQt5.QtWidgets import QListView, QSizePolicy, QMenu, QStyleFactory
|
||||||
|
|
||||||
@ -27,6 +30,29 @@ from qutebrowser.config import config
|
|||||||
from qutebrowser.utils import qtutils, utils, objreg
|
from qutebrowser.utils import qtutils, utils, objreg
|
||||||
|
|
||||||
|
|
||||||
|
def update_geometry(obj):
|
||||||
|
"""Weird WORKAROUND for some weird PyQt bug (probably).
|
||||||
|
|
||||||
|
This actually should be a method of DownloadView, but for some reason the
|
||||||
|
rowsInserted/rowsRemoved signals don't get disconnected from this method
|
||||||
|
when the DownloadView is deleted from Qt (e.g. by closing a window).
|
||||||
|
|
||||||
|
Here we check if obj ("self") was deleted and just ignore the event if so.
|
||||||
|
|
||||||
|
Original bug: https://github.com/qutebrowser/qutebrowser/issues/167
|
||||||
|
Workaround bug: https://github.com/qutebrowser/qutebrowser/issues/171
|
||||||
|
"""
|
||||||
|
def _update_geometry():
|
||||||
|
"""Actually update the geometry if the object still exists."""
|
||||||
|
if sip.isdeleted(obj):
|
||||||
|
return
|
||||||
|
obj.updateGeometry()
|
||||||
|
|
||||||
|
# If we don't use a singleShot QTimer, the geometry isn't updated correctly
|
||||||
|
# and won't include the new item.
|
||||||
|
QTimer.singleShot(0, _update_geometry)
|
||||||
|
|
||||||
|
|
||||||
class DownloadView(QListView):
|
class DownloadView(QListView):
|
||||||
|
|
||||||
"""QListView which shows currently running downloads as a bar.
|
"""QListView which shows currently running downloads as a bar.
|
||||||
@ -59,12 +85,9 @@ class DownloadView(QListView):
|
|||||||
self.setSpacing(1)
|
self.setSpacing(1)
|
||||||
self._menu = None
|
self._menu = None
|
||||||
model = objreg.get('download-model', scope='window', window=win_id)
|
model = objreg.get('download-model', scope='window', window=win_id)
|
||||||
model.rowsInserted.connect(lambda:
|
model.rowsInserted.connect(functools.partial(update_geometry, self))
|
||||||
QTimer.singleShot(0, self.updateGeometry))
|
model.rowsRemoved.connect(functools.partial(update_geometry, self))
|
||||||
model.rowsRemoved.connect(lambda:
|
model.dataChanged.connect(functools.partial(update_geometry, self))
|
||||||
QTimer.singleShot(0, self.updateGeometry))
|
|
||||||
model.dataChanged.connect(lambda:
|
|
||||||
QTimer.singleShot(0, self.updateGeometry))
|
|
||||||
self.setModel(model)
|
self.setModel(model)
|
||||||
self.setWrapping(True)
|
self.setWrapping(True)
|
||||||
self.setContextMenuPolicy(Qt.CustomContextMenu)
|
self.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||||
|
Loading…
Reference in New Issue
Block a user