Changeset 1014

Show
Ignore:
Timestamp:
07/31/08 06:38:42 (1 month ago)
Author:
MaierMan
Message:

early sessionManager shutdown

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/chrome/content/dta/manager.js

    r1013 r1014  
    153153                        startDownloads(window.arguments[0], window.arguments[1]); 
    154154                } 
    155  
    156155                this._initialized = true; 
    157156                for (let d in Tree.all) { 
     
    462461        close: function D_close() { 
    463462                Debug.logString("Close request"); 
     463                if (!this._initialized) { 
     464                        Debug.logString("not initialized. Going down immediately!"); 
     465                        return true; 
     466                } 
    464467                this.offline = true; 
    465468                if (!this._forceClose && !this._canClose()) { 
  • trunk/chrome/content/dta/manager/sessionmanager.js

    r1009 r1014  
    7777        }, 
    7878        shutdown: function() { 
    79                 try { 
    80                         for each (let e in ['_addStmt', '_saveStmt', '_savePosStmt', '_delStmt']) { 
    81                                 try { 
    82                                         this[e].finalize(); 
    83                                         delete this[e]; 
    84                                 } 
    85                                 catch (ex) { 
    86                                         // no-op 
    87                                 } 
    88                         } 
     79                // try to kill any loaders 
     80                if ('_loader' in this) { 
     81                        try { 
     82                                this._loader.cancel(); 
     83                                this.endUpdate(); 
     84                        } 
     85                        catch (ex) { 
     86                                // no-op 
     87                        } 
     88                } 
     89                for each (let e in ['_addStmt', '_saveStmt', '_savePosStmt', '_delStmt']) { 
     90                        try { 
     91                                this[e].finalize(); 
     92                                delete this[e]; 
     93                        } 
     94                        catch (ex) { 
     95                                // no-op 
     96                        } 
     97                } 
     98                try { 
    8999                        this._con.executeSimpleSQL('VACUUM'); 
    90                         try { 
    91                                 this._con.close(); 
    92                                 delete this._con; 
    93                         } 
    94                         catch (ex) { 
    95                                 Debug.log("Cannot close!", ex); 
    96                         } 
    97100                } 
    98101                catch (ex) { 
    99                         Debug.log("SessionManager::shutdown", ex); 
     102                        // no-op 
     103                } 
     104                try { 
     105                        this._con.close(); 
     106                        delete this._con; 
     107                } 
     108                catch (ex) { 
     109                        Debug.log("Cannot close!", ex); 
    100110                } 
    101111        }, 
     
    158168 
    159169        load: function() { 
    160                 this._loaded = false; 
    161                  
    162170                let stmt = this._con.createStatement('SELECT COUNT(*) FROM queue'); 
    163171                stmt.executeStep(); 
     
    169177                this.beginUpdate(); 
    170178                Tree.beginUpdate(); 
    171                 new CoThread( 
     179                this._loader = new CoThread( 
    172180                        function(idx) { 
    173                                 loading.value = _('loading', [++idx, count]); 
     181                                if (idx % 500 == 0) { 
     182                                        loading.label = _('loading', [idx, count]); 
     183                                } 
    174184                                // Are we done? 
    175185                                if (!stmt || !stmt.executeStep()) { 
     186                                        delete this._loader; 
    176187                                        this.endUpdate(); 
    177188                                        Tree.endUpdate(); 
     
    291302                                return true; 
    292303                        }, 
    293                         200, 
     304                        100, 
    294305                        this 
    295                 ).run(); 
     306                ); 
     307                this._loader.run(); 
    296308        } 
    297309};