BUGFIX: crashed when menu entry wider than 19 chars

This commit is contained in:
Robin Dietzel 2023-01-10 16:04:28 +01:00
parent 4ba4908f01
commit 74eceacf7e
2 changed files with 3 additions and 2 deletions

View File

@ -24,7 +24,7 @@ namespace floatpump::menu {
list.reserve(m_submenus.size() + m_entries.size()); list.reserve(m_submenus.size() + m_entries.size());
//Append al Submenus //Append all Submenus
for (auto &m_submenu: m_submenus) { for (auto &m_submenu: m_submenus) {
list.push_back(m_submenu->printLine()); list.push_back(m_submenu->printLine());
} }

View File

@ -11,7 +11,8 @@ namespace floatpump {
//We have 19 characters width for displaying the entry -> fill with spaces //We have 19 characters width for displaying the entry -> fill with spaces
int spaces = 19 - (m_name.length() + m_type.toString().length()); int spaces = 19 - (m_name.length() + m_type.toString().length());
std::string spacer; std::string spacer;
spacer.append(spaces, ' '); if(spaces > 0)
spacer.append(spaces, ' ');
return m_name + spacer + m_type.toString(); return m_name + spacer + m_type.toString();
} }