Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Commit

Permalink
Fix an issue in the JSON converter where we neglect to check for a nu…
Browse files Browse the repository at this point in the history
…ll parent

before trying to use it.
  • Loading branch information
brycelelbach committed Jan 12, 2021
1 parent 6692d62 commit 9f4d228
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/Doxybook/JsonConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,23 +263,25 @@ nlohmann::json Doxybook2::JsonConverter::getAsJson(const Node& node) const {
nlohmann::json json = convert(node);
nlohmann::json dataJson = convert(node, data);
json.insert(dataJson.begin(), dataJson.end());
if (node.getParent()->getKind() != Kind::INDEX) {
std::list<const Node*> list;
auto parent = node.getParent();
while (parent != nullptr) {
list.push_front(parent);
parent = parent->getParent();
if (parent && parent->getKind() == Kind::INDEX)
parent = nullptr;
}
nlohmann::json breadcrumbs = nlohmann::json::array();
for (const auto& ptr : list) {
breadcrumbs.push_back(convert(*ptr));
if (node.getParent() != nullptr) {
if (node.getParent()->getKind() != Kind::INDEX) {
std::list<const Node*> list;
auto parent = node.getParent();
while (parent != nullptr) {
list.push_front(parent);
parent = parent->getParent();
if (parent && parent->getKind() == Kind::INDEX)
parent = nullptr;
}
nlohmann::json breadcrumbs = nlohmann::json::array();
for (const auto& ptr : list) {
breadcrumbs.push_back(convert(*ptr));
}
json["parentBreadcrumbs"] = std::move(breadcrumbs);
json["parent"] = convert(*node.getParent());
} else {
json["parent"] = nullptr;
}
json["parentBreadcrumbs"] = std::move(breadcrumbs);
json["parent"] = convert(*node.getParent());
} else {
json["parent"] = nullptr;
}

if (node.getGroup() != nullptr) {
Expand Down

0 comments on commit 9f4d228

Please # to comment.