Project

General

Profile

array_index_out_2.txt

Sergey Ivanovskiy, 12/23/2015 05:53 AM

Download (3.24 KB)

 
1
=== modified file 'src/com/goldencode/p2j/ui/client/gui/ScrollBarGuiButton.java'
2
--- src/com/goldencode/p2j/ui/client/gui/ScrollBarGuiButton.java	2015-11-27 18:10:35 +0000
3
+++ src/com/goldencode/p2j/ui/client/gui/ScrollBarGuiButton.java	2015-12-23 10:35:20 +0000
4
@@ -30,6 +30,7 @@
5
 **                  we have to track the mouse release, not click.  Adding auto-scroll feature on
6
 **                  press and hold mouse button.  The mouse executor shoule be stopped on widget
7
 **                  destroy to free the resources.  Changing static executor to be instance based.
8
+** 012 SBI 20151223 Emits only valid auto scroll events.
9
 */
10
 
11
 package com.goldencode.p2j.ui.client.gui;
12
@@ -246,8 +247,11 @@
13
                         // emit the sequential scroll events
14
                         ScrollEvent evt =
15
                            ((ScrollBarGuiImpl)owner).createAutoScrollEvent(position);
16
-                                 
17
-                        tc.postOSEvent(evt);
18
+                        
19
+                        if (evt != null)
20
+                        {
21
+                           tc.postOSEvent(evt);
22
+                        }
23
                      }
24
                   }
25
                   catch (InterruptedException ex)
26

    
27
=== modified file 'src/com/goldencode/p2j/ui/client/gui/ScrollBarGuiImpl.java'
28
--- src/com/goldencode/p2j/ui/client/gui/ScrollBarGuiImpl.java	2015-11-27 18:10:35 +0000
29
+++ src/com/goldencode/p2j/ui/client/gui/ScrollBarGuiImpl.java	2015-12-23 10:46:56 +0000
30
@@ -40,6 +40,7 @@
31
 **                  to scroll - it is not required to draw the thumb.  Fix for background drawing.
32
 ** 019 EVL 20151125 Adding executor shutdown to prevent resource leak.  Changing static executor
33
 **                  to be instance based.
34
+** 020 SBI 20151223 Changed createAutoScrollEvent() to create only valid auto scroll events.
35
 */
36
 
37
 package com.goldencode.p2j.ui.client.gui;
38
@@ -749,23 +750,42 @@
39
    }
40
    
41
    /**
42
-    * Create GUI specific auto-scroll event.
43
-    * 
44
-    * @param   btn
45
-    *          The source button that caused the event.
46
+    * Create GUI specific auto-scroll event if the changed position is valid, otherwise it returns
47
+    * null indicating that it is not required to send scroll events due to the current scroller's
48
+    * position reaches its bounds. 
49
+    * 
50
+    * @param    btn
51
+    *           The source button that caused the event.
52
+    * 
53
+    * @return   Returns the valid scroll event if the current scroller's position doesn't reach
54
+    *           its bounds, otherwise null.
55
     */
56
    public ScrollEvent createAutoScrollEvent(Position btn)
57
    {
58
+      if (position >= max && btn == ScrollBar.Position.RIGHT
59
+               || position <= 0 && btn == ScrollBar.Position.LEFT)
60
+      {
61
+         return null;
62
+      }
63
+      
64
       // start with the current position
65
       int newPos = position;
66
-                        
67
+      
68
       if (btn == ScrollBar.Position.RIGHT)
69
       {
70
          newPos += shortStep;
71
+         if (newPos > max)
72
+         {
73
+            newPos = max;
74
+         }
75
       }
76
       else
77
       {
78
          newPos -= shortStep;
79
+         if (newPos < 0)
80
+         {
81
+            newPos = 0;
82
+         }
83
       }
84
       
85
       return createScrollEvent(newPos);
86