Don't return a name for a variable if it has no name, even if it's in a group that does have a name.

When displaying variables, don't display variables with no name, or that are groups.


git-svn-id: https://arducopter.googlecode.com/svn/trunk@1656 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
DrZiplok@gmail.com 2011-02-14 17:44:33 +00:00
parent b750e2b006
commit a8d6b839a5
2 changed files with 12 additions and 4 deletions

View File

@ -131,9 +131,11 @@ AP_Var::~AP_Var(void)
void AP_Var::copy_name(char *buffer, size_t buffer_size) const
{
buffer[0] = '\0';
if (_group)
_group->copy_name(buffer, buffer_size);
strlcat_P(buffer, _name, buffer_size);
if (_name) {
if (_group)
_group->copy_name(buffer, buffer_size);
strlcat_P(buffer, _name, buffer_size);
}
}
// Find a variable by name.

View File

@ -111,10 +111,16 @@ AP_Var_menu_show(uint8_t argc, const Menu::arg *argv)
for (vp = AP_Var::first(); vp; vp = vp->next()) {
char name_buffer[32];
// groups should not be displayed
if (vp->meta_type_id() == AP_Var::k_typeid_group) {
continue;
}
// get a displayable name for the variable
vp->copy_name(name_buffer, sizeof(name_buffer));
if (name_buffer[0] == 0) {
strcpy_P(name_buffer, PSTR("??"));
// without a name the variable is not displayable
continue;
}
// print name and value