fix bug on non existing path in path search
[scilab.git] / scilab / modules / graphic_objects / src / cpp / ScilabView.cpp
index 23ddc0e..88dfcb0 100644 (file)
@@ -494,27 +494,13 @@ PathItem* ScilabView::getItem(std::string _pstTag)
 
 PathItem* ScilabView::getItem(std::string _pstTag, std::list<int>& _ignoredList)
 {
-    /*
-    */
     __pathList_iterator it = m_pathList.begin();
     for (; it != m_pathList.end(); it++)
     {
         PathItem * item = it->second;
         if (item->tag == _pstTag)
         {
-            bool ignored = false;
-            //check if this handle is not in ignoredList
-            std::list<int>::iterator itIgnored = _ignoredList.begin();
-            for (; itIgnored != _ignoredList.end(); itIgnored++)
-            {
-                if ((*itIgnored) == item->uid)
-                {
-                    ignored = true;
-                    break;
-                }
-            }
-
-            if (ignored == false)
+            if (std::find(_ignoredList.begin(), _ignoredList.end(), item->uid) == _ignoredList.end())
             {
                 return item;
             }
@@ -565,13 +551,19 @@ int ScilabView::search_path(char* _pstPath)
                         break;
                     }
                 }
+
+                //if figure is in ignore list, reeturn not found
+                if (std::find(ignoredList.begin(), ignoredList.end(), path->uid) != ignoredList.end())
+                {
+                    return 0;
+                }
             }
             else
             {
                 PathItem* newPath = search_children(path, pstSubPath, bDeep, ignoredList);
                 if (newPath == NULL)
                 {
-                    //flag handle to ingnore and restart parsing
+                    //flag handle to ignore and restart parsing
                     ignoredList.push_back(path->uid);
                     pstPath = strdup(_pstPath);
                     pstSubPath = strtok(pstPath, "/");
@@ -613,17 +605,7 @@ PathItem* ScilabView::search_children(PathItem* _path, std::string _subPath, boo
         {
             bool ignored = false;
             //check if this handle is not in ignoredList
-            std::list<int>::iterator itIgnored = _ignoredList.begin();
-            for (; itIgnored != _ignoredList.end(); itIgnored++)
-            {
-                if ((*itIgnored) == child->uid)
-                {
-                    ignored = true;
-                    break;
-                }
-            }
-
-            if (ignored == false)
+            if (std::find(_ignoredList.begin(), _ignoredList.end(), child->uid) == _ignoredList.end())
             {
                 return child;
             }