Fix EvMenu infinite loop on empty-string key. Resolves #1769

This commit is contained in:
Griatch 2019-03-30 17:39:08 +01:00
parent cd375165b7
commit 37e8585b78

View file

@ -458,7 +458,6 @@ class EvMenu(object):
for key, val in kwargs.items():
setattr(self, key, val)
#
if self.caller.ndb._menutree:
# an evmenu already exists - we try to close it cleanly. Note that this will
# not fire the previous menu's end node.
@ -992,8 +991,7 @@ class EvMenu(object):
table_width_max = -1
table = []
for key, desc in optionlist:
if not (key or desc):
continue
if key or desc:
desc_string = ": %s" % desc if desc else ""
table_width_max = max(table_width_max,
max(m_len(p) for p in key.split("\n")) +
@ -1008,6 +1006,10 @@ class EvMenu(object):
ncols = (_MAX_TEXT_WIDTH // table_width_max) + 1 # number of ncols
if ncols <= 0:
# no visible option at all
return ""
# get the amount of rows needed (start with 4 rows)
nrows = 4
while nrows * ncols < nlist: