Skip to content

Commit

Permalink
Fixed bug when closing main window with unsaved changes (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilcardella committed Feb 15, 2020
1 parent 362f1ca commit 548c273
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Show application version in About dialog
- Support for yfinance module to fetch stocks data

### Fixed
- Fixed bug where main window was hidden when closing app with unsaved changes

## [2.1.1] - 2020-01-13
### Changed
- Removed unused resource files
Expand Down
7 changes: 5 additions & 2 deletions src/UI/gtk/UIHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _create_UI(self):
self._portfolio_path_label = builder.get_object(PORTFOLIO_PATH_LABEL)
self._connection_status_image = builder.get_object(CONNECTION_IMAGE)
# and link their callbacks
self._main_window.connect("destroy", self._on_close_main_window_event)
self._main_window.connect("delete-event", self._on_main_window_delete_event)
open_button.connect("clicked", self._on_open_portfolio_event)
settings_button.connect("clicked", self._on_open_settings_event)
about_button.connect("clicked", self._on_show_about_event)
Expand All @@ -67,7 +67,7 @@ def _create_UI(self):
for pf in self._client.get_portfolios():
self._create_update_portfolio_tab(pf)

def _on_close_main_window_event(self, widget):
def _on_main_window_delete_event(self, widget, event):
# Check if there are unsaved changes before closing the app
if self._client.unsaved_changes():
ConfirmDialog(
Expand All @@ -77,6 +77,9 @@ def _on_close_main_window_event(self, widget):
).show()
else:
self._close_application()
return False
# Return True to block event propagation
return True

def _close_application(self):
if self._log_window:
Expand Down

0 comments on commit 548c273

Please sign in to comment.