Skip to content
Snippets Groups Projects
Commit 536b9c4e authored by Marco Biasini's avatar Marco Biasini
Browse files

fight the symptoms of BZDNG-154

Not a complete fix: Accessing AtomHandles, ResidueHandles and ChainHandles whose
EntityHandle is out of scope still crashes. That requires larger refactoring
though.
parent a75bbdf7
No related branches found
No related tags found
No related merge requests found
...@@ -67,7 +67,10 @@ AtomView::AtomView(const ResidueView& residue_view, ...@@ -67,7 +67,10 @@ AtomView::AtomView(const ResidueView& residue_view,
ResidueView AtomView::GetResidue() const ResidueView AtomView::GetResidue() const
{ {
this->CheckValidity(); this->CheckValidity();
return ResidueView(data_->residue.lock(), Impl()->GetResidue()); if (!data_->residue.expired()) {
return ResidueView(data_->residue.lock(), Impl()->GetResidue());
}
throw InvalidHandle();
} }
void AtomView::Apply(EntityVisitor& visitor) void AtomView::Apply(EntityVisitor& visitor)
......
...@@ -79,7 +79,11 @@ ChainView::ChainView() { ...@@ -79,7 +79,11 @@ ChainView::ChainView() {
} }
EntityView ChainView::GetEntity() const { EntityView ChainView::GetEntity() const {
return EntityView(data_->entity.lock(), Impl()->GetEntity()); this->CheckValidity();
if (!data_->entity.expired()) {
return EntityView(data_->entity.lock(), Impl()->GetEntity());
}
throw InvalidHandle();
} }
ChainView::ChainView(const EntityView& entity, ChainView::ChainView(const EntityView& entity,
......
...@@ -138,7 +138,10 @@ const AtomViewList& ResidueView::GetAtomList() const { ...@@ -138,7 +138,10 @@ const AtomViewList& ResidueView::GetAtomList() const {
ChainView ResidueView::GetChain() const { ChainView ResidueView::GetChain() const {
this->CheckValidity(); this->CheckValidity();
return ChainView(data_->chain.lock(), Impl()->GetChain()); if (!data_->chain.expired()) {
return ChainView(data_->chain.lock(), Impl()->GetChain());
}
throw InvalidHandle();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment