Author: ptw
Date: 2007-12-20 07:37:35 -0800 (Thu, 20 Dec 2007)
New Revision: 7634

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/events/LaszloEvents.lzs
Log:
Change 20071105-ptw-V by [EMAIL PROTECTED] on 2007-11-05 15:10:35 EST
    in /Users/ptw/OpenLaszlo/ringding-2
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Ensure deferred events do not recurse

Bugs Fixed:
LPP-4950 'LzDelegate single-execution mechanism does not work for queued 
delegates'

Technical Reviewer: hminksy (pending)
QA Reviewer: [EMAIL PROTECTED] (message://<[EMAIL PROTECTED]>)

Details:
    More closely mimic sendEvent when processing deferred events by
    locking the event and delegate that was deferred from recursing.

Tests:
    Test case from bug no longer shows the event recursing.



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/events/LaszloEvents.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/events/LaszloEvents.lzs    2007-12-20 
15:37:05 UTC (rev 7633)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/events/LaszloEvents.lzs    2007-12-20 
15:37:35 UTC (rev 7634)
@@ -206,17 +206,31 @@
     var evq = this.__LZdelegatesQueue;
     var n = evq.length;
     var i = pos;
-    while (i < n) {
-      var d = evq[i];
-      var sd = evq[i+1];
-      /*
-      if ($debug) {
-        Debug.debug("Deferred %w.execute(%w)", d, sd);
+    if (i < n) {
+      var calledDelegates = new Array;
+      var lockedEvents = new Array;
+      while (i < n) {
+        var e = evq[i];
+        var d = evq[i+1];
+        var sd = evq[i+2];
+        // Mimic sendEvent which prohibits events and delegates from
+        // recursing
+        e.locked = true;
+        lockedEvents.push(e);
+        if (! d.event_called) {
+          d.event_called = true; //this delegate has been called
+          calledDelegates.push( d );
+          // d.execute( sd ); inlined
+          if (d.c[d.f]) d.c[d.f]( sd );
+        }
+        i+=3;
       }
-      */
-      // d.execute( sd ); inlined
-      if (d.c[d.f]) d.c[d.f]( sd );
-      i+=2;
+      while (d = calledDelegates.pop()) {
+        d.event_called = false;
+      }
+      while (e = lockedEvents.pop()) {
+        e.locked = false;
+      }
     }
     evq.length = pos;
   }
@@ -431,7 +445,7 @@
             // properly managed
             if (d.enabled && d.c) {
                 if (d.c.__LZdeferDelegates) {
-                    evq.push(d, sd);
+                  evq.push(this, d, sd);
                 } else {
                   // d.execute( sd ); inlined
                   if (d.c[d.f]) d.c[d.f]( sd );


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to