summaryrefslogtreecommitdiffstats
path: root/newt/build/newt-0.52.2-pgupdown-crash.patch
blob: f0fc646c8da3072ac6677c60a82597a6a2d560d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--- newt-0.52.2/checkboxtree.c.pgupdown-crash	2005-09-30 16:05:55.000000000 +0200
+++ newt-0.52.2/checkboxtree.c	2006-01-17 23:40:19.000000000 +0100
@@ -536,6 +536,18 @@
     free(co);
 }
 
+static void ctEnsureLimits( struct CheckboxTree *ct ) {
+    struct items **listEnd = ct->flatList + ct->flatCount - 1;
+    if (ct->firstItem < ct->flatList)
+        ct->firstItem = ct->flatList;
+    if (ct->currItem < ct->flatList)
+        ct->currItem = ct->flatList;
+    if (ct->firstItem > listEnd) {
+        ct->firstItem = listEnd;
+        ct->currItem = listEnd;
+    }
+}
+
 struct eventResult ctEvent(newtComponent co, struct event ev) {
     struct CheckboxTree * ct = co->data;
     struct eventResult er;
@@ -647,6 +659,7 @@
 		ct->currItem -= co->height;
 		ct->firstItem -= co->height;
 	    }
+	    ctEnsureLimits( ct );
 
 	    ctDraw(co);
 	    if(co->callback) co->callback(co, co->callbackData);
@@ -663,6 +676,7 @@
 	    	ct->currItem += co->height;
 		ct->firstItem += co->height;
 	    }
+	    ctEnsureLimits( ct );
 
 	    ctDraw(co);
 	    if(co->callback) co->callback(co, co->callbackData);