From a8d6b839a57c4cae4a5642b921c662de628aa8ce Mon Sep 17 00:00:00 2001 From: "DrZiplok@gmail.com" Date: Mon, 14 Feb 2011 17:44:33 +0000 Subject: [PATCH] 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 --- libraries/AP_Common/AP_Var.cpp | 8 +++++--- libraries/AP_Common/AP_Var_menufuncs.cpp | 8 +++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libraries/AP_Common/AP_Var.cpp b/libraries/AP_Common/AP_Var.cpp index c36ade1ac6..53e00fd816 100644 --- a/libraries/AP_Common/AP_Var.cpp +++ b/libraries/AP_Common/AP_Var.cpp @@ -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. diff --git a/libraries/AP_Common/AP_Var_menufuncs.cpp b/libraries/AP_Common/AP_Var_menufuncs.cpp index 217eca7bc9..61d2706cad 100644 --- a/libraries/AP_Common/AP_Var_menufuncs.cpp +++ b/libraries/AP_Common/AP_Var_menufuncs.cpp @@ -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