From b115aef19bca42965f03b7abb5ad8168da25de4a Mon Sep 17 00:00:00 2001 From: Manuel Riel Date: Mon, 4 Mar 2019 22:49:20 +0800 Subject: [PATCH] Reduce memory usage by removing main window from memory when closed. Fixes #207 (#208) --- src/vorta/application.py | 7 +++---- src/vorta/views/main_window.py | 1 + tests/conftest.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vorta/application.py b/src/vorta/application.py index ec4d2144..72aa14f8 100644 --- a/src/vorta/application.py +++ b/src/vorta/application.py @@ -50,9 +50,8 @@ def __init__(self, args_raw, single_app=False): self.setQuitOnLastWindowClosed(False) self.scheduler = VortaScheduler(self) - # Prepare tray and main window + # Prepare system tray icon self.tray = TrayMenu(self) - self.main_window = MainWindow(self) # Apply dark stylesheet if SettingsModel.get(key='use_dark_theme').value: @@ -60,7 +59,7 @@ def __init__(self, args_raw, single_app=False): args = parse_args() if hasattr(args, 'foreground') and args.foreground: - self.main_window.show() + self.open_main_window_action() self.backup_started_event.connect(self.backup_started_event_response) self.backup_finished_event.connect(self.backup_finished_event_response) @@ -79,6 +78,7 @@ def create_backup_action(self, profile_id=None): self.backup_log_event.emit(translate('messages', msg['message'])) def open_main_window_action(self): + self.main_window = MainWindow(self) self.main_window.show() self.main_window.raise_() @@ -93,7 +93,6 @@ def backup_started_event_response(self): def backup_finished_event_response(self): set_tray_icon(self.tray) - self.main_window.scheduleTab._draw_next_scheduled_backup() def backup_cancelled_event_response(self): set_tray_icon(self.tray) diff --git a/src/vorta/views/main_window.py b/src/vorta/views/main_window.py index 9be583e4..b9f26402 100644 --- a/src/vorta/views/main_window.py +++ b/src/vorta/views/main_window.py @@ -23,6 +23,7 @@ def __init__(self, parent=None): super().__init__() self.setupUi(self) self.setWindowTitle('Vorta for Borg Backup') + self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) self.app = parent self.current_profile = BackupProfileModel.select().order_by('id').first() self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.WindowMinimizeButtonHint) diff --git a/tests/conftest.py b/tests/conftest.py index 58432b21..2e748219 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -32,7 +32,7 @@ def app(tmpdir, qtbot): source_dir.save() app = VortaApp([]) - app.main_window.show() + app.open_main_window_action() qtbot.addWidget(app.main_window) return app