Fix EvMenu infinite loop on empty-string key. Resolves #1769
This commit is contained in:
parent
cd375165b7
commit
37e8585b78
1 changed files with 16 additions and 14 deletions
|
|
@ -458,7 +458,6 @@ class EvMenu(object):
|
||||||
for key, val in kwargs.items():
|
for key, val in kwargs.items():
|
||||||
setattr(self, key, val)
|
setattr(self, key, val)
|
||||||
|
|
||||||
#
|
|
||||||
if self.caller.ndb._menutree:
|
if self.caller.ndb._menutree:
|
||||||
# an evmenu already exists - we try to close it cleanly. Note that this will
|
# an evmenu already exists - we try to close it cleanly. Note that this will
|
||||||
# not fire the previous menu's end node.
|
# not fire the previous menu's end node.
|
||||||
|
|
@ -992,22 +991,25 @@ class EvMenu(object):
|
||||||
table_width_max = -1
|
table_width_max = -1
|
||||||
table = []
|
table = []
|
||||||
for key, desc in optionlist:
|
for key, desc in optionlist:
|
||||||
if not (key or desc):
|
if key or desc:
|
||||||
continue
|
desc_string = ": %s" % desc if desc else ""
|
||||||
desc_string = ": %s" % desc if desc else ""
|
table_width_max = max(table_width_max,
|
||||||
table_width_max = max(table_width_max,
|
max(m_len(p) for p in key.split("\n")) +
|
||||||
max(m_len(p) for p in key.split("\n")) +
|
max(m_len(p) for p in desc_string.split("\n")) + colsep)
|
||||||
max(m_len(p) for p in desc_string.split("\n")) + colsep)
|
raw_key = strip_ansi(key)
|
||||||
raw_key = strip_ansi(key)
|
if raw_key != key:
|
||||||
if raw_key != key:
|
# already decorations in key definition
|
||||||
# already decorations in key definition
|
table.append(" |lc%s|lt%s|le%s" % (raw_key, key, desc_string))
|
||||||
table.append(" |lc%s|lt%s|le%s" % (raw_key, key, desc_string))
|
else:
|
||||||
else:
|
# add a default white color to key
|
||||||
# add a default white color to key
|
table.append(" |lc%s|lt|w%s|n|le%s" % (raw_key, raw_key, desc_string))
|
||||||
table.append(" |lc%s|lt|w%s|n|le%s" % (raw_key, raw_key, desc_string))
|
|
||||||
|
|
||||||
ncols = (_MAX_TEXT_WIDTH // table_width_max) + 1 # number of ncols
|
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)
|
# get the amount of rows needed (start with 4 rows)
|
||||||
nrows = 4
|
nrows = 4
|
||||||
while nrows * ncols < nlist:
|
while nrows * ncols < nlist:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue