History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-5302
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: -- --
Assignee: Unassigned
Reporter: Max Carlson
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

LzTimer ignores disabled events

Created: 20/Dec/07 08:54 AM   Updated: 09/Jan/08 02:00 PM
Component/s: Laszlo Foundation Classes (LFC)
Affects Version/s: RingDing (4.1)
Fix Version/s: RingDing (4.1)

Time Tracking:
Not Specified

Severity: Minor
Fixed in Change#: 7,655
Runtime: N/A
Fix in hand: False


 Description  « Hide
Can't enable/disable delegates that are registered for timers. See this testcase:

<canvas debug="true">
   <simplelayout inset="10" axis="x" spacing="2"/>
   <button y="10" text="Timer" fontstyle="bold">
      <handler name="onclick">
         this.onclick.clearDelegates();
         this.del = new LzDelegate(this, "stopTimer");
         this.del.register(this, "onclick");
         time.updateTimer();
      </handler>
      <method name="stopTimer">
         time.del.disable();
         this.onclick.clearDelegates();
         this.del = new LzDelegate(this, "restartTimer");
         this.del.register(this, "onclick");
      </method>
      <method name="restartTimer">
         time.del.enable();
         time.updateTimer(this);
         this.onclick.clearDelegates();
         this.del = new LzDelegate(this, "stopTimer");
         this.del.register(this, "onclick");
      </method>
   </button>
   <text name="time" y="10" resize="true"
         fontsize="14" fontstyle="bold">
      <attribute name="elapsedTime" type="number" value="0"/>
      <method name="updateTimer">
         this.setAttribute('text', this.elapsedTime/10);
         this.elapsedTime++;
         if (typeof this.del == "undefined"){
            this.del = new LzDelegate(this, "updateTimer");
            LzTimer.addTimer(this.del, 100);}
         else LzTimer.resetTimer(this.del, 100);
      </method>
   </text>
</canvas>

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Max Carlson - 21/Dec/07 09:11 AM
Author: max
Date: 2007-12-21 07:38:05 -0800 (Fri, 21 Dec 2007)
New Revision: 7655

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/events/LaszloEvents.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/services/LzTimer.lzs
Log:
Change 20071220-maxcarlson-X by maxcarlson@Roboto.local on 2007-12-20 13:13:36 PST
    in /Users/maxcarlson/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: UPDATED - Fix enable/disabling of delegates bound to lztimer

New Features:

Bugs Fixed: LPP-5302 - LzTimer ignores disabled events

Technical Reviewer: promanik
QA Reviewer: ptw
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details: Check if a context is deleted before executing the delegate. Add more comments to keep track of inlining, fix inlining to match implementation of execute(). We need compiler inlining!!!
    

Tests: smoketest and testcase in LPP-5302 passes.



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/events/LaszloEvents.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/events/LaszloEvents.lzs 2007-12-21 15:30:46 UTC (rev 7654)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/events/LaszloEvents.lzs 2007-12-21 15:38:05 UTC (rev 7655)
@@ -87,8 +87,9 @@
     // 'resurrect' the deleted view, causing a memory leak
     // Usually this is because a deleted view has idle or timer events
     // still registered.
+ // inlined in LzDelegate.sendEvent(), __LZdrainDelegatesQueue(), and LzTimer.addTimer();
     var context = this.c;
- if (context) {
+ if (this.enabled && context) {
         if (context['__LZdeleted']) {
             return;
         }
@@ -221,7 +222,7 @@
           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 );
+ if (d.c && ! d.c.__LZdeleted && d.c[d.f]) d.c[d.f]( sd );
         }
         i+=3;
       }
@@ -448,7 +449,7 @@
                   evq.push(this, d, sd);
                 } else {
                   // d.execute( sd ); inlined
- if (d.c[d.f]) d.c[d.f]( sd );
+ if (d.c && ! d.c.__LZdeleted && d.c[d.f]) d.c[d.f]( sd );
                 }
             }
         }

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/services/LzTimer.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/services/LzTimer.lzs 2007-12-21 15:30:46 UTC (rev 7654)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/services/LzTimer.lzs 2007-12-21 15:38:05 UTC (rev 7655)
@@ -75,7 +75,12 @@
         // User LzTimer explicitly below; "this" is not the outer function's
         // this here.
         LzTimer.removeTimerWithID(p.delegate, p.id);
- p.delegate.execute( (new Date()).getTime() );
+ var del = p.delegate;
+ // Inlining LzDelegate.execute()
+ if (del.enabled && del.c) {
+ //p.delegate.execute( (new Date()).getTime() ); inlined
+ if (! del.c.__LZdeleted && del.c[del.f]) del.c[del.f]( (new Date()).getTime() );
+ }
     }
     var id = setInterval(f, milisecs);
     if ($debug) {

Mamye Kratt - 09/Jan/08 02:00 PM
(trunk 4 local build r7775)
smokecheck.lzx returns the following in swf7 and swf8
  Tests: 845 Failures: 0 Errors: 0

smokecheck.lzx returns the following in dhtml
  Tests: 836 Failures: 0 Errors: 0

Ran the following testfile successfully in swf and dhtml:
<canvas debug="true">
   <simplelayout inset="10" axis="x" spacing="2"/>
   <button y="10" text="Timer" fontstyle="bold">
      <handler name="onclick">
         this.onclick.clearDelegates();
         this.del = new LzDelegate(this, "stopTimer");
         this.del.register(this, "onclick");
         time.updateTimer();
      </handler>
      <method name="stopTimer">
         time.del.disable();
         this.onclick.clearDelegates();
         this.del = new LzDelegate(this, "restartTimer");
         this.del.register(this, "onclick");
      </method>
      <method name="restartTimer">
         time.del.enable();
         time.updateTimer(this);
         this.onclick.clearDelegates();
         this.del = new LzDelegate(this, "stopTimer");
         this.del.register(this, "onclick");
      </method>
   </button>
   <text name="time" y="10" resize="true"
         fontsize="14" fontstyle="bold">
      <attribute name="elapsedTime" type="number" value="0"/>
      <method name="updateTimer">
         this.setAttribute('text', this.elapsedTime/10);
         this.elapsedTime++;
         if (typeof this.del == "undefined"){
            this.del = new LzDelegate(this, "updateTimer");
            LzTimer.addTimer(this.del, 100);}
         else LzTimer.resetTimer(this.del, 100);
      </method>
   </text>
</canvas>