Ticket #6393: ticket6393.patch

File ticket6393.patch, 1.7 kB (added by guest, 9 months ago)

Suggested patch - CLA submitted and acknowledged.

  • hostenv_rhino.js

     
    195195        return document.body;    
    196196} 
    197197 
    198 dojo._timeouts = []; 
     198// Supply setTimeout/clearTimeout implementations if they aren't already there 
     199try{ 
     200        setTimeout; 
     201        clearTimeout; 
     202}catch(e){ 
     203        dojo._timeouts = []; 
    199204 
    200 function clearTimeout(idx){ 
    201         if(!dojo._timeouts[idx]){ return; } 
    202         dojo._timeouts[idx].stop(); 
    203 } 
     205        function clearTimeout(idx){ 
     206                if(!dojo._timeouts[idx]){ return; } 
     207                dojo._timeouts[idx].stop(); 
     208        } 
    204209 
    205 function setTimeout(func, delay){ 
    206         // summary: provides timed callbacks using Java threads 
     210        function setTimeout(func, delay){ 
     211                // summary: provides timed callbacks using Java threads 
    207212 
    208         var def={ 
    209                 sleepTime:delay, 
    210                 hasSlept:false, 
     213                var def={ 
     214                        sleepTime:delay, 
     215                        hasSlept:false, 
    211216                 
    212                 run:function(){ 
    213                         if(!this.hasSlept){ 
    214                                 this.hasSlept=true; 
    215                                 java.lang.Thread.currentThread().sleep(this.sleepTime); 
     217                        run:function(){ 
     218                                if(!this.hasSlept){ 
     219                                        this.hasSlept=true; 
     220                                        java.lang.Thread.currentThread().sleep(this.sleepTime); 
     221                                } 
     222                                try{ 
     223                                        func(); 
     224                                }catch(e){ 
     225                                        console.debug("Error running setTimeout thread:" + e); 
     226                                } 
    216227                        } 
    217                         try{ 
    218                                 func(); 
    219                         }catch(e){ 
    220                                 console.debug("Error running setTimeout thread:" + e); 
    221                         } 
    222                 } 
    223         }; 
     228                }; 
    224229         
    225         var runnable = new java.lang.Runnable(def); 
    226         var thread = new java.lang.Thread(runnable); 
    227         thread.start(); 
    228         return dojo._timeouts.push(thread)-1; 
     230                var runnable = new java.lang.Runnable(def); 
     231                var thread = new java.lang.Thread(runnable); 
     232                thread.start(); 
     233                return dojo._timeouts.push(thread)-1; 
     234        } 
    229235} 
    230236 
    231237//Register any module paths set up in djConfig. Need to do this