From: Jim Procter Date: Mon, 1 Aug 2016 07:49:54 +0000 (+0100) Subject: JAL-1772 make sure we actually return reference to AlignFrame that is visible after... X-Git-Tag: Release_2_10_0~127^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=74d1897e700018c3a1eb01b6d6ed94f26b171824;p=jalview.git JAL-1772 make sure we actually return reference to AlignFrame that is visible after views are gathered --- diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 1633a5d..f12d106 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -2276,12 +2276,20 @@ public class Jalview2XML if (true) // !skipViewport(object)) { _af = loadFromObject(object, file, true, jprovider); - if (object.getJalviewModelSequence().getViewportCount() > 0) + if (_af != null + && object.getJalviewModelSequence().getViewportCount() > 0) { - af = _af; - if (af.viewport.isGatherViewsHere()) + if (af == null) { - gatherToThisFrame.put(af.viewport.getSequenceSetId(), af); + // store a reference to the first view + af = _af; + } + if (_af.viewport.isGatherViewsHere()) + { + // if this is a gathered view, keep its reference since + // after gathering views, only this frame will remain + af = _af; + gatherToThisFrame.put(_af.viewport.getSequenceSetId(), _af); } } } diff --git a/test/jalview/io/Jalview2xmlTests.java b/test/jalview/io/Jalview2xmlTests.java index 26fba58..915625f 100644 --- a/test/jalview/io/Jalview2xmlTests.java +++ b/test/jalview/io/Jalview2xmlTests.java @@ -371,12 +371,19 @@ public class Jalview2xmlTests @Test(groups = { "Functional" }, enabled = true) public void testStoreAndRecoverExpandedviews() throws Exception { + AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded( "examples/exampleFile_2_7.jar", FormatAdapter.FILE); assertTrue("Didn't read in the example file correctly.", af != null); String afid = af.getViewport().getSequenceSetId(); - Desktop.explodeViews(Desktop.getAlignFrameFor(af.getViewport())); + // check FileLoader returned a reference to the one alignFrame that is + // actually on the Desktop + assertTrue( + "Jalview2XML.loadAlignFrame() didn't return correct AlignFrame reference for multiple view window", + af == Desktop.getAlignFrameFor(af.getViewport())); + + Desktop.explodeViews(af); int oldviews = Desktop.getAlignFrames().length; Assert.assertEquals(Desktop.getAlignFrames().length,