Simplify TempDownloadManager initialization

This commit is contained in:
Florian Bruhin 2016-11-01 17:35:53 +01:00
parent 7ca6996f39
commit e985730cbf
3 changed files with 7 additions and 7 deletions

View File

@ -435,8 +435,6 @@ def _init_modules(args, crash_handler):
os.environ['QT_WAYLAND_DISABLE_WINDOWDECORATION'] = '1'
else:
os.environ.pop('QT_WAYLAND_DISABLE_WINDOWDECORATION', None)
temp_downloads = downloads.TempDownloadManager(qApp)
objreg.register('temporary-downloads', temp_downloads)
# Init backend-specific stuff
browsertab.init(args)

View File

@ -907,7 +907,7 @@ class DownloadModel(QAbstractListModel):
return len(self)
class TempDownloadManager(QObject):
class TempDownloadManager:
"""Manager to handle temporary download files.
@ -919,8 +919,7 @@ class TempDownloadManager(QObject):
files: A list of NamedTemporaryFiles of downloaded items.
"""
def __init__(self, parent=None):
super().__init__(parent)
def __init__(self):
self.files = []
self._tmpdir = None
@ -969,3 +968,6 @@ class TempDownloadManager(QObject):
suffix=suggested_name)
self.files.append(fobj)
return fobj
temp_download_manager = TempDownloadManager()

View File

@ -358,9 +358,9 @@ class DownloadItem(downloads.AbstractDownloadItem):
elif isinstance(target, usertypes.FileDownloadTarget):
self.set_filename(target.filename)
elif isinstance(target, usertypes.OpenFileDownloadTarget):
tmp_manager = objreg.get('temporary-downloads')
try:
fobj = tmp_manager.get_tmpfile(self.basename)
fobj = downloads.temp_download_manager.get_tmpfile(
self.basename)
except OSError as exc:
msg = "Download error: {}".format(exc)
message.error(msg)