MASON-INTEREST-L Archives

February 2015

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Thu, 5 Feb 2015 13:28:40 -0500
MIME-version:
1.0 (Mac OS X Mail 7.3 \(1878.6\))
Reply-To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Content-type:
text/plain; charset=us-ascii
Subject:
From:
Sean Luke <[log in to unmask]>
In-Reply-To:
Message-ID:
Content-Transfer-Encoding:
8bit
Parts/Attachments:
text/plain (37 lines)
Well, that is just amazingly stupid.  Who would have thought that removeAll() would first set the selected index to -1 (but not remove the tabs yet) and *then* call the listeners, and only *then* remove the remaining tabs?

I have committed an additional check in TabbedInspector.updateDisplayedInspector().  Lemme know if you find any other errors.

Sean

On Feb 5, 2015, at 11:12 AM, Christian Meyer <[log in to unmask]> wrote:

> Hello!
> 
> If TabbedInspector.clear() is called JtabbedPane.removeAll() will set the selected index to -1. The change event fired thereafter will lead to an ArrayIndexOutOfBoundsException in TabbedInspector.updateDisplayedInspector() because there is no check for invalid indices and the tab count is still > 0.
> 
> Tested with mason revision 1010 and OpenJDK version "1.7.0_75".
> 
> Best regards,
> Christian
> 
> import sim.portrayal.Inspector;
> import sim.portrayal.inspector.TabbedInspector;
> 
> public class TestTabbedInspector {
>    public static void main(String[] args) {
> 	TabbedInspector tabbedInspector = new TabbedInspector();
> 
> 	Inspector blankInspector = new Inspector() {
> 	    private static final long serialVersionUID = 1L;
> 
> 	    @Override
> 	    public void updateInspector() {
> 	    }
> 	};
> 
> 	tabbedInspector.addInspector(blankInspector);
> 	tabbedInspector.clear();
>    }
> }

ATOM RSS1 RSS2