Simplify how parseElement splits element string (#9726)
authorPierre-Yves Rollo <dev@pyrollo.com>
Sat, 25 Apr 2020 05:48:04 +0000 (07:48 +0200)
committerGitHub <noreply@github.com>
Sat, 25 Apr 2020 05:48:04 +0000 (07:48 +0200)
src/gui/guiFormSpecMenu.cpp

index 85ab2eb509e531aeef6c6e0f5d87759ef088890f..0ed525f978e6295675435a668c7d3331974ab8df 100644 (file)
@@ -2668,24 +2668,12 @@ void GUIFormSpecMenu::parseElement(parserData* data, const std::string &element)
        if (parseVersionDirect(element))
                return;
 
-       std::vector<std::string> parts = split(element,'[');
-
-       // ugly workaround to keep compatibility
-       if (parts.size() > 2) {
-               if (trim(parts[0]) == "image") {
-                       for (unsigned int i=2;i< parts.size(); i++) {
-                               parts[1] += "[" + parts[i];
-                       }
-               }
-               else { return; }
-       }
-
-       if (parts.size() < 2) {
+       size_t pos = element.find('[');
+       if (pos == std::string::npos)
                return;
-       }
 
-       std::string type = trim(parts[0]);
-       std::string description = trim(parts[1]);
+       std::string type = trim(element.substr(0, pos));
+       std::string description = element.substr(pos+1);
 
        if (type == "container") {
                parseContainer(data, description);