From e5edd3d9da88468dc7143f7e46cf2ebbe4e3393c Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 24 Aug 2007 15:38:29 +0000 Subject: [PATCH] dataset alignments have a reference count which must be zero before they are finalized. --- src/jalview/datamodel/Alignment.java | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index c474142..ba65fd7 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -190,7 +190,7 @@ public class Alignment public void finalize() { if(getDataset()!=null) - getDataset().finalize(); + getDataset().removeAlignmentRef(); dataset = null; sequences = null; @@ -199,6 +199,16 @@ public class Alignment hiddenSequences = null; } + /** + * decrement the alignmentRefs counter by one and call finalize if it goes to zero. + */ + private void removeAlignmentRef() + { + if (--alignmentRefs==0) + { + finalize(); + } + } /** * DOCUMENT ME! @@ -638,6 +648,18 @@ public class Alignment { dataset = data; } + dataset.addAlignmentRef(); + } + /** + * reference count for number of alignments referencing this one. + */ + int alignmentRefs=0; + /** + * increase reference count to this alignment. + */ + private void addAlignmentRef() + { + alignmentRefs++; } public Alignment getDataset() -- 1.7.10.2