break non-windowGroup expose-poll loop after a while (10 seconds)
authorClaus Gittinger <cg@exept.de>
Tue, 19 Aug 1997 17:28:51 +0200
changeset 1872 2a10e693d93f
parent 1871 a8e7a9b8923b
child 1873 a67649816bc8
break non-windowGroup expose-poll loop after a while (10 seconds) to avoid blocking forever.
DSurface.st
DisplaySurface.st
SWSensor.st
SynchronousWindowSensor.st
--- a/DSurface.st	Tue Aug 19 17:13:20 1997 +0200
+++ b/DSurface.st	Tue Aug 19 17:28:51 1997 +0200
@@ -1308,7 +1308,7 @@
 waitForExpose
     "wait until an expose event arrives (to wait for scroll-finish)"
 
-    |wg|
+    |wg endPollTime|
 
     device scrollsAsynchronous ifFalse:[
         gotExpose := true.
@@ -1317,26 +1317,42 @@
 
     wg := self windowGroup.
     wg notNil ifTrue:[
-        "
-         a normal (suspendable) view.
-         wait by doing a real wait
-        "
+        "/
+        "/ a normal (suspendable) view.
+        "/ wait by doing a real wait
+        "/
          wg waitForExposeFor:self
     ] ifFalse:[
-        "
-         a pure event driven view.
-         wait by doing a direct dispatch loop until the event arrives.
-        "
+        "/
+        "/ a pure event driven view.
+        "/ wait by doing a direct dispatch loop until the event arrives.
+        "/ i.e. poll for the event
+        "/
+        endPollTime := AbsoluteTime now addSeconds:10.
+
         [gotExpose] whileFalse:[
-            device dispatchExposeEventFor:drawableId.
+            realized ifTrue:[
+                (device exposeEventPendingFor:drawableId withSync:true) ifTrue:[
+                    device dispatchExposeEventFor:drawableId.
+                ].
+            ].
             realized ifFalse:[
                 gotExpose := true.
                 ^ self
-            ]
+            ].
+
+            "/ break out of the poll after a while
+
+            AbsoluteTime now > endPollTime ifTrue:[
+                'DisplaySurface [warning]: lost expose event' errorPrintCR.
+                gotExpose := true.
+                ^ self
+            ].
+            Processor yield.
         ].
     ]
 
-    "Modified: 18.1.1997 / 18:09:28 / cg"
+    "Modified: 19.8.1997 / 17:22:46 / cg"
 ! !
 
 !DisplaySurface methodsFor:'initialize / release'!
@@ -1666,5 +1682,5 @@
 !DisplaySurface class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Attic/DSurface.st,v 1.31 1997-08-07 11:00:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Attic/DSurface.st,v 1.32 1997-08-19 15:28:27 cg Exp $'
 ! !
--- a/DisplaySurface.st	Tue Aug 19 17:13:20 1997 +0200
+++ b/DisplaySurface.st	Tue Aug 19 17:28:51 1997 +0200
@@ -1308,7 +1308,7 @@
 waitForExpose
     "wait until an expose event arrives (to wait for scroll-finish)"
 
-    |wg|
+    |wg endPollTime|
 
     device scrollsAsynchronous ifFalse:[
         gotExpose := true.
@@ -1317,26 +1317,42 @@
 
     wg := self windowGroup.
     wg notNil ifTrue:[
-        "
-         a normal (suspendable) view.
-         wait by doing a real wait
-        "
+        "/
+        "/ a normal (suspendable) view.
+        "/ wait by doing a real wait
+        "/
          wg waitForExposeFor:self
     ] ifFalse:[
-        "
-         a pure event driven view.
-         wait by doing a direct dispatch loop until the event arrives.
-        "
+        "/
+        "/ a pure event driven view.
+        "/ wait by doing a direct dispatch loop until the event arrives.
+        "/ i.e. poll for the event
+        "/
+        endPollTime := AbsoluteTime now addSeconds:10.
+
         [gotExpose] whileFalse:[
-            device dispatchExposeEventFor:drawableId.
+            realized ifTrue:[
+                (device exposeEventPendingFor:drawableId withSync:true) ifTrue:[
+                    device dispatchExposeEventFor:drawableId.
+                ].
+            ].
             realized ifFalse:[
                 gotExpose := true.
                 ^ self
-            ]
+            ].
+
+            "/ break out of the poll after a while
+
+            AbsoluteTime now > endPollTime ifTrue:[
+                'DisplaySurface [warning]: lost expose event' errorPrintCR.
+                gotExpose := true.
+                ^ self
+            ].
+            Processor yield.
         ].
     ]
 
-    "Modified: 18.1.1997 / 18:09:28 / cg"
+    "Modified: 19.8.1997 / 17:22:46 / cg"
 ! !
 
 !DisplaySurface methodsFor:'initialize / release'!
@@ -1666,5 +1682,5 @@
 !DisplaySurface class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/DisplaySurface.st,v 1.31 1997-08-07 11:00:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/DisplaySurface.st,v 1.32 1997-08-19 15:28:27 cg Exp $'
 ! !
--- a/SWSensor.st	Tue Aug 19 17:13:20 1997 +0200
+++ b/SWSensor.st	Tue Aug 19 17:28:51 1997 +0200
@@ -324,21 +324,42 @@
 waitForExposeFor:aView
     "wait until a graphicsExpose or a noExpose arrives (after a bitblt)."
 
-    "
-     cannot suspend, I am a synchronous-modal sensor
-    "
-    [ (gotExpose includes:aView) ] whileFalse:[
-        aView graphicsDevice dispatchExposeEventFor:aView id.
-        Processor yield.
+    |device windowId stopPoll endPollTime|
+
+    device := aView graphicsDevice.
+
+    "/ this is only needed for X ...
+    device scrollsAsynchronous ifTrue:[
+        windowId := aView id.
+
+        "/
+        "/ cannot suspend, I am a synchronous-modal sensor
+        "/ must poll for the event
+        "/
+        endPollTime := AbsoluteTime now addSeconds:10.
+        stopPoll := false.
+
+        [(gotExpose includes:aView) or:[stopPoll]] whileFalse:[
+            (device exposeEventPendingFor:windowId withSync:true) ifTrue:[
+                device dispatchExposeEventFor:windowId.
+            ].
+            stopPoll := (AbsoluteTime now > endPollTime).
+            Processor yield.
+        ].
+
+        stopPoll ifTrue:[
+            'SyncWindowSensor [warning]: lost expose event' errorPrintCR.
+        ]
     ].
+
     catchExpose remove:aView ifAbsent:nil.
     gotExpose remove:aView ifAbsent:nil.
 
-    "Modified: 29.1.1997 / 20:44:38 / cg"
+    "Modified: 19.8.1997 / 17:25:09 / cg"
 ! !
 
 !SynchronousWindowSensor class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Attic/SWSensor.st,v 1.14 1997-01-29 19:59:32 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Attic/SWSensor.st,v 1.15 1997-08-19 15:28:51 cg Exp $'
 ! !
--- a/SynchronousWindowSensor.st	Tue Aug 19 17:13:20 1997 +0200
+++ b/SynchronousWindowSensor.st	Tue Aug 19 17:28:51 1997 +0200
@@ -324,21 +324,42 @@
 waitForExposeFor:aView
     "wait until a graphicsExpose or a noExpose arrives (after a bitblt)."
 
-    "
-     cannot suspend, I am a synchronous-modal sensor
-    "
-    [ (gotExpose includes:aView) ] whileFalse:[
-        aView graphicsDevice dispatchExposeEventFor:aView id.
-        Processor yield.
+    |device windowId stopPoll endPollTime|
+
+    device := aView graphicsDevice.
+
+    "/ this is only needed for X ...
+    device scrollsAsynchronous ifTrue:[
+        windowId := aView id.
+
+        "/
+        "/ cannot suspend, I am a synchronous-modal sensor
+        "/ must poll for the event
+        "/
+        endPollTime := AbsoluteTime now addSeconds:10.
+        stopPoll := false.
+
+        [(gotExpose includes:aView) or:[stopPoll]] whileFalse:[
+            (device exposeEventPendingFor:windowId withSync:true) ifTrue:[
+                device dispatchExposeEventFor:windowId.
+            ].
+            stopPoll := (AbsoluteTime now > endPollTime).
+            Processor yield.
+        ].
+
+        stopPoll ifTrue:[
+            'SyncWindowSensor [warning]: lost expose event' errorPrintCR.
+        ]
     ].
+
     catchExpose remove:aView ifAbsent:nil.
     gotExpose remove:aView ifAbsent:nil.
 
-    "Modified: 29.1.1997 / 20:44:38 / cg"
+    "Modified: 19.8.1997 / 17:25:09 / cg"
 ! !
 
 !SynchronousWindowSensor class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/SynchronousWindowSensor.st,v 1.14 1997-01-29 19:59:32 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/SynchronousWindowSensor.st,v 1.15 1997-08-19 15:28:51 cg Exp $'
 ! !