Skip to content

Commit

Permalink
Fix unhandled exception when adding recent menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
otsaloma committed Jun 27, 2017
1 parent f45f325 commit 8d1b06d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Gaupol 1.2.1/1.3
================

* [x] Fix unhandled exception when adding recent menu items
18 changes: 12 additions & 6 deletions gaupol/agents/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,18 @@ def _update_recent_main_menu(self, *args):
action = "win.open-recent-main-file-{:d}".format(i)
menu.append(label, action)
action = action.replace("win.", "")
if not self.get_action(action):
ao = gaupol.Action(action)
callback = self._on_open_recent_main_file_activate
ao.connect("activate", callback)
self.window.add_action(ao)
self.get_action(action).gaupol_path = path
if self.get_action(action):
# If action i exists, update the file path.
self.get_action(action).gaupol_path = path
else:
# Otherwise, create the action and add to self.window.
# XXX: For some reason, this can sometimes fail.
with aeidon.util.silent(Exception):
ao = gaupol.Action(action)
ao.gaupol_path = path
callback = self._on_open_recent_main_file_activate
ao.connect("activate", callback)
self.window.add_action(ao)

def _update_recent_menus(self, *args):
"""Update the file menu lists of recent files."""
Expand Down

0 comments on commit 8d1b06d

Please sign in to comment.