OSDN Git Service

version 0.5.21, bugfix around ApplicationReferance.shutdown().
authoritozyun <itozyun@gmail.com>
Thu, 15 Nov 2012 12:57:36 +0000 (21:57 +0900)
committeritozyun <itozyun@gmail.com>
Thu, 15 Nov 2012 12:57:36 +0000 (21:57 +0900)
0.5.x/javascripts/system.js

index 358d03a..265a0f3 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * pettanR system.js
- *   version 0.5.20
+ *   version 0.5.21
  *
  * gadgetOS
  *   author:
@@ -1701,13 +1701,13 @@ var PointingDeviceEventTree = ( function(){
                removeEventListener : function( eventType, handler ){
                        var events  = this.events,
                                counter = this.rootData.eventCounter,
-                               type, list, i;
+                               type, list, i = 0;
                        if( events === null ) return;
                        console.log( ' *** remove ' + eventType );
                        for( type in events ){
                                list = events[ type ];
                                if( eventType && eventType !== type ) continue;
-                               for( i = 0; i < list.length; ){
+                               for( ; i < list.length; ){
                                        if( list[ i ].destroy( type, handler ) === true ){
                                                console.log( ' *** removed! ' + type );
                                                list.splice( i, 1 );
@@ -1719,12 +1719,14 @@ var PointingDeviceEventTree = ( function(){
                                        // delete this[ type ];
                                        delete events[ type ];
                                };
-                               --counter[ type ];
-                               if( counter[ type ] === 0 ){
-                                       MouseEvent.remove( this.apiuser, this.rootData.elmMouseCatch, type, eventRellay );
-                                       delete counter[ type ];
+                               if( counter[ type ] ){
+                                       --counter[ type ];
+                                       if( counter[ type ] === 0 ){
+                                               MouseEvent.remove( this.apiuser, this.rootData.elmMouseCatch, type, eventRellay );
+                                               delete counter[ type ];
+                                       };
                                };
-                       };                      
+                       };
                },
                _eventRellay : function( x, y, e, eventType ){
                        if( this._disabled === true ) return false; 
@@ -1847,30 +1849,6 @@ var PointingDeviceEventTree = ( function(){
                        };
                        return this._scrollY;
                },
-               remove : function(){
-                       if( this === this.rootData ) return;
-                       var parent = this.parentData,
-                               list   = NodePrivateData.dataList,
-                               nodes  = this.childData,
-                               node;
-                       this._destroy();
-                       if( parent.hitChild === this ) parent.hitChild = null;
-                       if( parent.childData.length === 0 ) delete parent.childData;    
-                       parent.clip === false && parent._updateRectangle();
-               },
-               _destroy : function(){
-                       var nodes = this.childData,
-                               list  = NodePrivateData.dataList,
-                               node;
-                       this.removeEventListener();
-                       if( nodes ){
-                               while( node = nodes.shift() ) node._destroy();
-                       };
-                       list.splice( Util.getIndex( list, this ), 1 );
-                       if( !this.parentData ) return;
-                       nodes = this.parentData.childData;
-                       nodes.splice( Util.getIndex( nodes, this ), 1 );
-               },
                nodeIndex : function( v ){
                        var list, i;
                        if( !this.parentData ) return 0;
@@ -1910,6 +1888,27 @@ var PointingDeviceEventTree = ( function(){
                                this._childDisabled = v;
                        };
                        return this._childDisabled;
+               },
+               remove : function(){
+                       if( this === this.rootData ) return;
+                       var parent = this.parentData,
+                               nodes  = parent.childData;
+                       this._destroy();
+                       if( parent.hitChild === this ) delete parent.hitChild;
+                       nodes.splice( Util.getIndex( nodes, this ), 1 );
+                       if( nodes.length === 0 ) delete parent.childData;       
+                       parent.clip === false && parent._updateRectangle();
+               },
+               _destroy : function(){
+                       var nodes = this.childData,
+                               list  = NodePrivateData.dataList,
+                               node;
+                       this.removeEventListener();
+                       if( nodes ){
+                               while( node = nodes.shift() ) node._destroy();
+                               delete this.childData;
+                       };
+                       list.splice( Util.getIndex( list, this ), 1 );
                }
        };
        NodePrivateData.dataList = [];
@@ -2102,8 +2101,13 @@ var PointingDeviceEventTree = ( function(){
                        var data = NodePrivateData.get( root );
                        MouseEvent.remove( data.apiuser, data.elmMouseCatch, 'mousemove', eventRellay );
                        body.removeChild( data.elmMouseCatch );
-                       NodePrivateData.get( root )._destroy();
-                       ROOT_LIST.splice( Util.getIndex( ROOT_LIST, root ), 1 );
+                       data._destroy();
+                       ROOT_LIST.splice( Util.getIndex( ROOT_LIST, data ), 1 );
+                       if( currentRootData === data ){
+                               currentRootData    = null;
+                               targetNodeData     = null;
+                               forceNodeData      = null;      
+                       };
                },
                onSystemShutdown : function(){
                        
@@ -2142,8 +2146,7 @@ var Application = ( function(){
                this.shutdown = function(){
                        if( !application ) return false;
                        
-                       if( ( isOverlay === true ? Overlay.hide() : application.close() ) === false ) return false;
-                       application = null;
+                       AsyncCall.add( application, ( isOverlay === true ? Overlay.hide : application.close ) );
                };
        };