Skip to content

Commit d87746a

Browse files
committed
melddoc: Log when our action helpers don't find named actions
This helps quite a bit during these migrations.
1 parent 2d46310 commit d87746a

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

meld/melddoc.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,25 @@ def set_labels(self, lst):
189189

190190
def get_action_state(self, action_name: str):
191191
action = self.view_action_group.lookup_action(action_name)
192+
if not action:
193+
log.error(f'No action {action_name!r} found')
194+
return
192195
return action.get_state().unpack()
193196

194197
def set_action_state(self, action_name: str, state):
195198
# TODO: Try to do GLib.Variant things here instead of in callers
196-
self.view_action_group.lookup_action(action_name).set_state(state)
199+
action = self.view_action_group.lookup_action(action_name)
200+
if not action:
201+
log.error(f'No action {action_name!r} found')
202+
return
203+
action.set_state(state)
197204

198-
def set_action_enabled(self, action, enabled):
199-
self.view_action_group.lookup_action(action).set_enabled(enabled)
205+
def set_action_enabled(self, action_name, enabled):
206+
action = self.view_action_group.lookup_action(action_name)
207+
if not action:
208+
log.error(f'No action {action_name!r} found')
209+
return
210+
action.set_enabled(enabled)
200211

201212
def on_container_switch_in_event(self, uimanager, window):
202213
"""Called when the container app switches to this tab.

0 commit comments

Comments
 (0)