git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
JAL-2089 fix broken help link
[jalview.git]
/
src
/
jalview
/
datamodel
/
Alignment.java
diff --git
a/src/jalview/datamodel/Alignment.java
b/src/jalview/datamodel/Alignment.java
index
fd918fc
..
35ee8c4
100755
(executable)
--- a/
src/jalview/datamodel/Alignment.java
+++ b/
src/jalview/datamodel/Alignment.java
@@
-226,18
+226,21
@@
public class Alignment implements AlignmentI
{
if (dataset != null)
{
{
if (dataset != null)
{
+
// maintain dataset integrity
// maintain dataset integrity
- if (snew.getDatasetSequence() != null)
- {
- getDataset().addSequence(snew.getDatasetSequence());
- }
- else
+ SequenceI dsseq = snew.getDatasetSequence();
+ if (dsseq == null)
{
// derive new sequence
SequenceI adding = snew.deriveSequence();
{
// derive new sequence
SequenceI adding = snew.deriveSequence();
- getDataset().addSequence(adding.getDatasetSequence());
snew = adding;
snew = adding;
+ dsseq = snew.getDatasetSequence();
}
}
+ if (getDataset().findIndex(dsseq) == -1)
+ {
+ getDataset().addSequence(dsseq);
+ }
+
}
if (sequences == null)
{
}
if (sequences == null)
{
@@
-287,13
+290,23
@@
public class Alignment implements AlignmentI
}
@Override
}
@Override
- public void finalize()
+ public void finalize() throws Throwable
{
if (getDataset() != null)
{
getDataset().removeAlignmentRef();
}
{
if (getDataset() != null)
{
getDataset().removeAlignmentRef();
}
+ nullReferences();
+ super.finalize();
+ }
+
+ /**
+ * Defensively nulls out references in case this object is not garbage
+ * collected
+ */
+ void nullReferences()
+ {
dataset = null;
sequences = null;
groups = null;
dataset = null;
sequences = null;
groups = null;
@@
-302,14
+315,16
@@
public class Alignment implements AlignmentI
}
/**
}
/**
- * decrement the alignmentRefs counter by one and call finalize if it goes to
- * zero.
+ * decrement the alignmentRefs counter by one and null references if it goes
+ * to zero.
+ *
+ * @throws Throwable
*/
*/
- private void removeAlignmentRef()
+ private void removeAlignmentRef() throws Throwable
{
if (--alignmentRefs == 0)
{
{
if (--alignmentRefs == 0)
{
- finalize();
+ nullReferences();
}
}
}
}