tn5250j patch
Kenneth Pouncey <[email protected]> Wed, 26 Oct 2005 08:13:30 +0200
| Newsgroups | gmane.comp.java.tn5250j.general |
|---|---|
| Message-ID | <[email protected]> |
Patrick another Mitch Blevins <[email protected]> There appears to be a bug where if a ScreenListener removes itself during an onScreenChanged() call, the firing code will continue to loop through the now-structurally changed Vector. This causes indeterminate behavior and has resulted in several crashes on my side. Fixes in the patch below for you review. Mitch Blevins IT Manager International Environmental _http://www.iec-okc.com/_ <javascript:ol('http://www.iec-okc.com/');> Index: C:/eclipse/workspace/Jumper2/src/org/tn5250j/framework/tn5250/Screen5250.java =================================================================== --- C:/eclipse/workspace/Jumper2/src/org/tn5250j/framework/tn5250/Screen5250.java (revision 1499) +++ C:/eclipse/workspace/Jumper2/src/org/tn5250j/framework/tn5250/Screen5250.java (revision 1500) @@ -3897,12 +3897,12 @@ */ private void fireScreenChanged(int which, int startRow, int startCol, int endRow, int endCol) { - if (listeners != null) { - int size = listeners.size(); + Vector lc = new Vector(listeners); + int size = lc.size(); for (int i = 0; i < size; i++) { ScreenListener target = - (ScreenListener)listeners.elementAt(i); + (ScreenListener)lc.elementAt(i); target.onScreenChanged(1,startRow,startCol,endRow,endCol); } } @@ -3933,10 +3933,11 @@ int startCol = getCol(lastPos); if (listeners != null) { - int size = listeners.size(); + Vector lc = new Vector(listeners); + int size = lc.size(); for (int i = 0; i < size; i++) { ScreenListener target = - (ScreenListener)listeners.elementAt(i); + (ScreenListener)lc.elementAt(i); target.onScreenChanged(update,startRow,startCol,startRow,startCol); } } @@ -3949,10 +3950,11 @@ private void fireScreenSizeChanged() { if (listeners != null) { - int size = listeners.size(); + Vector lc = new Vector(listeners); + int size = lc.size(); for (int i = 0; i < size; i++) { ScreenListener target = - (ScreenListener)listeners.elementAt(i); + (ScreenListener)lc.elementAt(i); target.onScreenSizeChanged(numRows,numCols); } }