From c4f4373f770199ac2b346c8034d873177de63490 Mon Sep 17 00:00:00 2001
From: andreas <andreas@5a81b35b-ba03-0410-adc8-b2c5c5119f08>
Date: Wed, 21 Jul 2010 18:03:51 +0000
Subject: [PATCH] bugfix in InfoGroup do_group_lookup

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2580 5a81b35b-ba03-0410-adc8-b2c5c5119f08
---
 modules/info/src/info_group.cc | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/modules/info/src/info_group.cc b/modules/info/src/info_group.cc
index de5d158a0..fcc6fb708 100644
--- a/modules/info/src/info_group.cc
+++ b/modules/info/src/info_group.cc
@@ -169,16 +169,25 @@ bool InfoGroup::do_group_lookup(std::vector<String>::const_iterator& pos,
 } 
 
 bool InfoGroup::do_group_lookup(std::vector<String>::const_iterator& pos,
-                                const std::vector<String>::const_iterator& end,
-                                InfoGroup& subgroup) const
+				const std::vector<String>::const_iterator& end,
+				InfoGroup& subgroup) const
 {
-  InfoGroupList subgroups;
-  if (this->do_group_lookup(pos, end, subgroups)) {
-    subgroup.Swap(subgroups.front());
+  if(pos==end) {
     return true;
   }
+  if(impl_->HasSub(*pos)) {
+    InfoGroup subgrp(root_,impl_->GetSub(*pos));
+    // remember last valid group
+    subgroup = subgrp;
+    ++pos;
+    if(pos==end) {
+      return true;
+    } else {
+      return subgrp.do_group_lookup(pos,end,subgroup);
+    }
+  }
   return false;
-}
+} 
 
 bool InfoGroup::HasGroup(const InfoPath& path, bool use_defaults) const
 {
@@ -210,6 +219,7 @@ InfoGroup InfoGroup::RetrieveGroup(const InfoPath& path, bool use_defaults)
     return GetGroup(path);
   } else {
     std::vector<String> plist=path.GetList();
+    if(plist.empty()) return *this;
     InfoGroup last_group(*this);
     std::vector<String>::const_iterator pos=plist.begin();
     bool ret=do_group_lookup(pos,plist.end(),last_group);
-- 
GitLab