Skip to content
Snippets Groups Projects
Commit 90b45594 authored by Bienchen's avatar Bienchen
Browse files

Fixed BZDNG-246; modified AtomImpl::DeleteAllTorsions() and test_view/...

Fixed BZDNG-246; modified AtomImpl::DeleteAllTorsions() and test_view/ test_delete which produced a memeory leak.
parent d9685272
No related branches found
No related tags found
No related merge requests found
...@@ -356,20 +356,21 @@ String AtomImpl::GetStringProperty(Prop::ID prop_id) const ...@@ -356,20 +356,21 @@ String AtomImpl::GetStringProperty(Prop::ID prop_id) const
void AtomImpl::DeleteAllTorsions() { void AtomImpl::DeleteAllTorsions() {
EntityImplPtr e=this->GetEntity(); EntityImplPtr e=this->GetEntity();
TorsionImplMap::iterator i; TorsionImplMap::iterator i;
while (true) { std::vector<TorsionImplMap::iterator> t_rm_vec;
for (i=e->GetTorsionMap().begin(); i!=e->GetTorsionMap().end(); ++i) { for (i=e->GetTorsionMap().begin(); i!=e->GetTorsionMap().end(); ++i) {
if (i->second->IsAtomInvolved(shared_from_this())) { if (i->second->IsAtomInvolved(shared_from_this())) {
e->GetTorsionMap().erase(i); t_rm_vec.push_back(i);
continue; }
} }
} std::vector<TorsionImplMap::iterator>::iterator it_rm;
break; for (it_rm=t_rm_vec.begin(); it_rm!=t_rm_vec.end(); ++it_rm) {
e->GetTorsionMap().erase(*it_rm);
} }
TorsionImplList& l=this->GetResidue()->GetTorsionList(); TorsionImplList& l=this->GetResidue()->GetTorsionList();
TorsionImplList::iterator j; TorsionImplList::iterator j;
j=std::remove_if(l.begin(), l.end(), j=std::remove_if(l.begin(), l.end(),
bind(&TorsionImpl::IsAtomInvolved, _1, shared_from_this())); bind(&TorsionImpl::IsAtomInvolved, _1, shared_from_this()));
l.erase(j, l.end()); l.erase(j, l.end());
} }
}}} // ns }}} // ns
...@@ -77,4 +77,4 @@ BOOST_AUTO_TEST_CASE(atom_delete) ...@@ -77,4 +77,4 @@ BOOST_AUTO_TEST_CASE(atom_delete)
BOOST_CHECK_NO_THROW(f.e.Apply(ev)); BOOST_CHECK_NO_THROW(f.e.Apply(ev));
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
using namespace ost; using namespace ost;
using namespace ost::mol; using namespace ost::mol;
struct Fixture { struct FixtureView {
Fixture() { FixtureView() {
e=CreateEntity(); e=CreateEntity();
XCSEditor editor=e.EditXCS(); XCSEditor editor=e.EditXCS();
c=editor.InsertChain("A"); c=editor.InsertChain("A");
...@@ -54,7 +54,7 @@ BOOST_AUTO_TEST_SUITE( mol_base ) ...@@ -54,7 +54,7 @@ BOOST_AUTO_TEST_SUITE( mol_base )
BOOST_AUTO_TEST_CASE(gen_full_view) BOOST_AUTO_TEST_CASE(gen_full_view)
{ {
Fixture f; FixtureView f;
EntityView ev = f.e.CreateFullView(); EntityView ev = f.e.CreateFullView();
BOOST_CHECK_EQUAL(ev.GetChainCount(),f.e.GetChainCount()); BOOST_CHECK_EQUAL(ev.GetChainCount(),f.e.GetChainCount());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment