From 0f56dd918b022c84cba63a810c75a386a7fe38b3 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Thu, 10 Oct 2019 10:34:22 +0200 Subject: guiconfig: Check for visible nodes before turning off show-all in full-tree mode If there are no visible nodes in the entire tree, guiconfig automatically starts in show-all mode. Previously, there was no check for visible nodes when turning off show-all in full-tree mode in this case, leading to errors. Fix it by checking if there are any visible nodes in the top menu when turning off show-all in full-tree mode. If there aren't, show-all stays on. --- guiconfig.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'guiconfig.py') diff --git a/guiconfig.py b/guiconfig.py index 20ecfa1..d333be4 100755 --- a/guiconfig.py +++ b/guiconfig.py @@ -1475,9 +1475,8 @@ def _toggle_showall(_): def _do_showall(): # Updates the UI for the current show-all setting - # Don't allow turning off show-all if we're in single-menu mode and the - # current menu would become empty - if _single_menu and not _shown_menu_nodes(_cur_menu): + # Don't allow turning off show-all if we'd end up with no visible nodes + if _nothing_shown(): _show_all_var.set(True) return @@ -1512,6 +1511,17 @@ def _do_showall(): _tree.focus_set() +def _nothing_shown(): + # _do_showall() helper. Returns True if no nodes would get + # shown with the current show-all setting. Also handles the + # (obscure) case when there are no visible nodes in the entire + # tree, meaning guiconfig was automatically started in + # show-all mode, which mustn't be turned off. + + return not _shown_menu_nodes( + _cur_menu if _single_menu else _kconf.top_node) + + def _toggle_tree_mode(_): # Toggles single-menu mode on/off -- cgit v1.2.3