From: <va...@us...> - 2009-03-21 05:13:13
|
Revision: 14816 http://jedit.svn.sourceforge.net/jedit/?rev=14816&view=rev Author: vanza Date: 2009-03-21 05:13:06 +0000 (Sat, 21 Mar 2009) Log Message: ----------- Fix some suspicious code that could be the cause of bug #2654976. . one code path was updating the "lastParent" cache variable but not "lastList", which could end up triggering an NPE later on. . in another method, the code looked confused between "child" and "parent". Modified Paths: -------------- plugins/ProjectViewer/trunk/projectviewer/vpt/ProjectCustomTreeModel.java Modified: plugins/ProjectViewer/trunk/projectviewer/vpt/ProjectCustomTreeModel.java =================================================================== --- plugins/ProjectViewer/trunk/projectviewer/vpt/ProjectCustomTreeModel.java 2009-03-21 04:28:47 UTC (rev 14815) +++ plugins/ProjectViewer/trunk/projectviewer/vpt/ProjectCustomTreeModel.java 2009-03-21 05:13:06 UTC (rev 14816) @@ -110,13 +110,13 @@ return Collections.binarySearch(lastList, (VPTNode) child); } - VPTNode node = (VPTNode) child; + VPTNode node = (VPTNode) parent; if (node.isGroup()) { return super.getIndexOfChild(parent, child); } else if (node.isProject()) { lastParent = parent; - return Collections.binarySearch(getCachedChildren((VPTProject) node), - (VPTNode) child); + lastList = getCachedChildren((VPTProject) node); + return Collections.binarySearch(lastList, (VPTNode) child); } assert (false) : "should not reach here"; return -1; @@ -235,13 +235,13 @@ */ protected List<VPTNode> getCachedChildren(VPTProject proj) { - List<VPTNode> lst = childCache.get(proj); - if (lst == null) { - lst = getChildren(proj); - Collections.sort(lst); - childCache.put(proj, lst); - } - return lst; + List<VPTNode> lst = childCache.get(proj); + if (lst == null) { + lst = getChildren(proj); + Collections.sort(lst); + childCache.put(proj, lst); + } + return lst; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |