Skip to content

Commit

Permalink
Allow groups with name=".." in extra settings
Browse files Browse the repository at this point in the history
Allow storing of children in a current branch without creation of new named sub-branch
  • Loading branch information
Wohlstand committed Jan 6, 2020
1 parent e3a3679 commit 09b494d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
28 changes: 21 additions & 7 deletions LunaDll/FileManager/config_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,21 +515,35 @@ static void read_layout_branches(nlohmann::json &typetree,
for(auto it = src.begin(); it != src.end(); it++)
{
nlohmann::json &entry = *it;
std::string name;
std::string control;

if(entry.find("control") == entry.end())
continue; // invalid entry: missing required key
if(entry.find("name") == entry.end())
continue; // invalid entry: missing required key
control = "invalid";
else
control = entry["control"];

std::string control = entry["control"];
std::string name = entry["name"];
if(entry.find("name") == entry.end())
name = control;
else
name = entry["name"];

if(SDL_strncasecmp(control.c_str(), "group", 6) == 0)
{
if(entry.find("children") == entry.end())
continue; // Invalid entry: missing a required key
nlohmann::json path_arr_next = path_arr;
path_arr_next.push_back(name);
read_layout_branches(typetree, dst[name], entry["children"], path_arr_next);
if(name != "..")
{
// Create a new named branch and store all children inside
path_arr_next.push_back(name);
read_layout_branches(typetree, dst[name], entry["children"], path_arr_next);
}
else
{
// Store all children in a current branch
read_layout_branches(typetree, dst, entry["children"], path_arr_next);
}
}
else if(SDL_strncasecmp(control.c_str(), "spinbox", 8) == 0)
{
Expand Down
5 changes: 4 additions & 1 deletion test/extra-settings/lles-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ static const char *test_str1 =
" \"whereIsMySombrero\": {"
" \"x\": 9,"
" \"y\": 12"
" }"
" },"
"\"zzzzzzzzzzzzzzzzzzzzzzzz1\": 28,"
"\"zzzzzzzzzzzzzzzzzzzzzzzz2\": \"22r`2`r2r``2r\","
"\"zzzzzzzzzzzzzzzzzzzzzzzz3\": \"popa\""
"}";

static const char *test_str2 =
Expand Down

0 comments on commit 09b494d

Please sign in to comment.