From d4463ba1b5a719ea30979ef1279682674d0452dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thies=20M=C3=B6ller?= Date: Fri, 12 Aug 2022 11:06:32 +0200 Subject: [PATCH] featurewalker: selector name stripping breaks if name contains "_" Enumeration and node names could contain an underscore. Strip of prefix part now only depends on length of prefix. --- ext/pylon/gstpylonfeaturewalker.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/pylon/gstpylonfeaturewalker.cpp b/ext/pylon/gstpylonfeaturewalker.cpp index de63ee8..71dbfda 100644 --- a/ext/pylon/gstpylonfeaturewalker.cpp +++ b/ext/pylon/gstpylonfeaturewalker.cpp @@ -98,10 +98,15 @@ static std::vector gst_pylon_camera_handle_node( /* Add selector enum values */ std::vector enum_values; GenApi::NodeList_t enum_entries; + /* calculate prefix length to strip */ + const auto prefix_str = std::string("EnumEntry_") + + enum_node->GetNode()->GetName().c_str() + + std::string("_"); + auto prefix_len = prefix_str.length(); enum_node->GetEntries(enum_entries); for (auto const& e : enum_entries) { auto enum_name = std::string(e->GetName()); - enum_values.push_back(enum_name.substr(enum_name.find_last_of("_") + 1)); + enum_values.push_back(enum_name.substr(prefix_len)); } selector_node = selector->GetNode();