From 8d1b06db6bc8ec3d5650ee92188a3c78f19061ea Mon Sep 17 00:00:00 2001 From: Osmo Salomaa Date: Tue, 27 Jun 2017 21:27:12 +0300 Subject: [PATCH] Fix unhandled exception when adding recent menu items --- TODO.md | 4 ++++ gaupol/agents/menu.py | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index e69de29b..ca645a2f 100644 --- a/TODO.md +++ b/TODO.md @@ -0,0 +1,4 @@ +Gaupol 1.2.1/1.3 +================ + +* [x] Fix unhandled exception when adding recent menu items diff --git a/gaupol/agents/menu.py b/gaupol/agents/menu.py index dfc51164..e00c21b7 100644 --- a/gaupol/agents/menu.py +++ b/gaupol/agents/menu.py @@ -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."""