From 9939d45f997d2855218e3acf5b51222e9680ce31 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Fri, 23 Sep 2005 20:13:52 +0000 Subject: [PATCH] Protecciones contra cuelgues. --- viewer/view_btree.cpp | 11 +++++++++++ viewer/view_btree.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/viewer/view_btree.cpp b/viewer/view_btree.cpp index f62e931..5c54a87 100644 --- a/viewer/view_btree.cpp +++ b/viewer/view_btree.cpp @@ -23,6 +23,12 @@ ViewBTree::ViewBTree (Canvas::Group *parent, std::string filename):Canvas::Group void ViewBTree::AddNode (uint num) { + if (node_placed[num]) { + std::cout << "WARNING : Tratando de agregar de nuevo el nodo " << num << std::endl; + return; + } + + node_placed[num] = true; /* Muestro la raiz */ double y = 0; uchar *node = ReadBlock (num); @@ -46,6 +52,11 @@ void ViewBTree::AddNode (uint num) std::list childs = vnode->getChilds (); std::list::iterator hit = childs.begin (); while (hit != childs.end ()) { + if ((*hit) == 0) { + std::cout << "WARNING : Referencia a 0 encontrada!!" << std::endl; + hit = childs.end (); + continue; + } AddNode (*hit); hit++; } diff --git a/viewer/view_btree.h b/viewer/view_btree.h index bd4f22c..e3a5c68 100644 --- a/viewer/view_btree.h +++ b/viewer/view_btree.h @@ -21,6 +21,9 @@ class ViewBTree : public Canvas::Group, public BTree { int max_level; /* Lo saco de la raiz */ /* Posicion X por nivel */ std::map pos_x; + /* Control para no poner 2 veces un nodo */ + /* Un nodo que quiera ser puesto 2 veces es un bug :) */ + std::map node_placed; void AddNode (uint num); -- 2.43.0