From 971e3099ff22470f173ba6aed9225efa200d9262 Mon Sep 17 00:00:00 2001 From: nedko Date: Mon, 22 May 2023 19:45:55 +0300 Subject: [PATCH] Fixed mindgen crashing on nodes without ID. Removed ghost print --- mindgen.cpp | 6 +++--- mindgen_funcs.cpp | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/mindgen.cpp b/mindgen.cpp index 6713864..e387a07 100644 --- a/mindgen.cpp +++ b/mindgen.cpp @@ -7,7 +7,7 @@ using namespace std; void printTree(MindNode* root) -{/* +{ if (root != NULL) { cout << "ID: " << root->getID() << endl; @@ -25,7 +25,7 @@ void printTree(MindNode* root) cout << "RIGHT" << endl; printTree(root->getNextNode()); } - cout << "UP" << endl;*/ + cout << "UP" << endl; } int main(int argc, char** argv) @@ -48,7 +48,7 @@ int main(int argc, char** argv) return -1; } - printTree(root); + // printTree(root); write_html(output_file, root); delete root; diff --git a/mindgen_funcs.cpp b/mindgen_funcs.cpp index fc637a5..7a694da 100644 --- a/mindgen_funcs.cpp +++ b/mindgen_funcs.cpp @@ -242,7 +242,6 @@ parse_mindmap(istream& in, MindNode** root) generate_map(content, current_tag); // Map parse - if ("map" == current_tag.name) { if (NULL != current_node) @@ -262,7 +261,10 @@ parse_mindmap(istream& in, MindNode** root) { MindNode* node_new = new MindNode(); - node_new->setID(current_tag.params.find("ID")->second); + if (current_tag.params.end() != current_tag.params.find("ID")) + { + node_new->setID(current_tag.params.find("ID")->second); + } if (current_tag.params.end() != current_tag.params.find("TEXT")) { @@ -313,7 +315,6 @@ parse_mindmap(istream& in, MindNode** root) } } } - cout << endl; return 0; }