Avoid a (theoretical) race condition when installing repeat blocks
authorStefan Vogel <sv@exept.de>
Wed, 11 May 2005 17:09:24 +0200
changeset 3164 78412bd19e6d
parent 3163 ed196eb1fa44
child 3165 58b08c376a6e
Avoid a (theoretical) race condition when installing repeat blocks
Scroller.st
--- a/Scroller.st	Wed May 11 16:30:47 2005 +0200
+++ b/Scroller.st	Wed May 11 17:09:24 2005 +0200
@@ -1001,9 +1001,13 @@
 !
 
 installRepeat:repeatDelay
-    repeatBlock notNil ifTrue:[
+    |repeatBlockCopy|
+
+    "protect against races"
+    repeatBlockCopy := repeatBlock.
+    repeatBlockCopy notNil ifTrue:[
         self repairDamage.
-        Processor addTimedBlock:repeatBlock afterSeconds:repeatDelay
+        Processor addTimedBlock:repeatBlockCopy afterSeconds:repeatDelay
     ]
 !
 
@@ -1482,7 +1486,6 @@
             ].
             repeatBlock := [self sensor pushUserEvent:#repeatPageUp for:self].
             sensor pushUserEvent:#installRepeat: for:self withArgument:initialRepeatDelay.
-            "/ Processor addTimedBlock:repeatBlock afterSeconds:initialRepeatDelay
         ]
     ] ifFalse:[
         (curr > limit2) ifTrue:[
@@ -1494,7 +1497,6 @@
                 ].
                 repeatBlock := [self sensor pushUserEvent:#repeatPageDown for:self].
                 sensor pushUserEvent:#installRepeat: for:self withArgument:initialRepeatDelay.
-                "/ Processor addTimedBlock:repeatBlock afterSeconds:initialRepeatDelay
             ]
         ] ifFalse:[
             pressOffset := curr - limit1.
@@ -2647,5 +2649,5 @@
 !Scroller class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.181 2005-05-11 14:30:47 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.182 2005-05-11 15:09:24 stefan Exp $'
 ! !